# Filtering

{% hint style="success" %}
This is the official documentation of Forest Admin Cloud.
{% endhint %}

### Emulation

To quickly make a field filterable, you can use filtering emulation. This method works best for collections with a few thousand records or less. It's a straightforward way to get started without much setup.

***

To make the code easier to read, all the code snippets below should be wrapped in the following code. Ensure you update the collection and field names as needed.

```typescript
import type { Agent } from '@forestadmin/forest-cloud';
import { Schema } from '../typings';

export default function customizeAgent(agent: Agent<Schema>) {
  agent.customizeCollection('users', (collection) => {
    // Insert the code snippet here.
  });
}
```

#### Enabling filtering emulation for all operators

```typescript
collection.emulateFieldFiltering('fullName');
```

#### Enabling filtering emulation for a single operator

```javascript
collection.emulateFieldOperator('fullName', 'Equal');
```

***

{% hint style="info" %}
Using fields emulation can impact the performance of your admin panel. It is crucial to review [best practices for fields ](/cloud/best-practices/performance.md#fields)to guarantee an optimal experience for your admin panel users.
{% endhint %}

### Overriding filtering

The `replaceFieldOperator()` method can be used to improve the search capabilities by defining custom operators for filtering on fields that are not directly filterable. This method allows for the efficient performance of filtering operations based on computed fields or non-filterable fields.

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

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

To enable searching on a field, it is necessary to have at least the following operators implemented for each respective field type:

* *<mark style="color:green;">Number</mark>*: Equal
* *<mark style="color:green;">Enum</mark>*: Equal
* *<mark style="color:green;">String</mark>*: IContains, Contains, or Equal
* *<mark style="color:green;">Uuid</mark>*: 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/cloud/code-customization/fields/filtering.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.
