<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.filters.CoalesceFilter.html -->
# CoalesceFilter

**`class CoalesceFilter(config)`**

Bases: [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter)

The coalesce [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) returns the first value which is set from
a list of fields. Any string or list is accepted as the valid value,
None is treated as not having been set.

**Input** - any type can be used for the input fields.

**Output** - the output field is filled with data of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – coalesce
- `input_fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)) – Fields to look at
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Field to store the resulting value

**Example**

```json
{
    "step": "filter",
    "type": "coalesce",
    "input_fields": ["clean_body", "body"],
    "output_field": "processing_body"
}
```

Methods SummaryMethods Documentation

**`process_doc(doc)`**

Process a document

Parameters

`doc` ([`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)) – Document

Returns

Processed document

Return type

[Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)
