# Override filtering behavior

{% hint style="success" %}
This is the official documentation of the `@forestadmin/agent` Node.js agent.
{% endhint %}

You may want to read about the following topics before using those features:

* [Unlocking filtering, scopes, and segments on the UI](https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/custom/translation/capabilities#unlock-filtering-scopes-and-segments-on-ui)
* [Structure of a `ConditionTree`](https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/getting-started/queries/filters#examples)
* [List of all filtering Operators](https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/getting-started/queries/filters#operators)
* [Operator equivalence system](https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/getting-started/queries/filters#operator-equivalence)

### Disabling operators

{% hint style="info" %}
Disabling filtering can be made without any code [in the field settings](https://docs.forestadmin.com/user-guide/collections/customize-your-fields#basic-settings).
{% endhint %}

### Substitution

Operation substitution can be used for two motives:

* Performance: provide a more efficient way to perform a given filtering operation
* Capabilities: enable filtering on a computed field or other non-filterable fields

```javascript
collection.replaceFieldOperator('fullName', 'Equal', (value, context) => {
  const [firstName, ...lastNames] = value.split(' ');

  return {
    aggregator: 'And',
    conditions: [
      { field: 'firstName', operator: 'Equal', value: firstName },
      { field: 'lastName', operator: 'Equal', value: lastNames.join(' ') },
    ],
  };
});
```

### Operators to support to enable the search

| Column Type | Operator to support            |
| ----------- | ------------------------------ |
| Number      | Equal                          |
| Enum        | Equal                          |
| String      | IContains OR Contains OR Equal |
| Uuid        | Equal                          |

You can use the [replaceFieldOperator](#substitution) method to unlock the operators.

### Emulation

Filtering emulation allows making fields filterable automatically. It is a convenient way to get things working quickly for Collections that have a low number of records (in the thousands at most).

{% hint style="warning" %}
This emulation forces the Agent to retrieve all the Collection records and compute the field values for each one of them. As a consequence, filtering emulation performance cost is **linear** with the number of records in the Collection, so **activate it sparingly and with great care**.
{% endhint %}

```javascript
// Add support for all operators
collection.emulateFieldFiltering('fullName');

// Add support for a single operator
collection.emulateFieldOperator('fullName', 'Equal');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/developer-guide-agents-nodejs/agent-customization/fields/filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
