# Adding searchable fields

**Search functionality is only enabled, if the LokiAdminComponents logic is able to find searchable fields for the current provider. This depends on the provider handler used (`repository`, `collection`, `array`) and on the arguments passed via the XML layout.**

## Searchable fields in the XML layout
You can hard-code the fields (columns) that should be searched through via the block argument `searchable_fields`.

```xml
<block>
    <arguments>
        <argument name="searchable_fields" xsi:type="array">
            <item name="identifier" xsi:type="string">identifier</item>
            <item name="title" xsi:type="string">title</item>
        </argument>
    </arguments>
</block>
```

See the [grid reference](/admin-components/grid/reference-grid-arguments) for more details.

## Searchable fields with arrays
When the provider handler `array` is used, the provider (the class that implements `Loki\AdminComponents\Provider\ArrayProviderInterface`) needs to implement a method `getColumns()` and this method is used to supply the searchable fields. In other words, by default, all fields are searched through.

## Searchable fields with collections
When the provider handler `collection` is used, the provider (aka the collection class) provides access to the underlying resource model, which is returning all used columns. In other words, by default, all fields are searched through.

## Searchable fields with repositories
When the provider handler `repository` is used, the provider unfortunately does not provide any hint on what kind of fields the returned objects will include, so what searchable fields would be available.

```xml
<block>
    <arguments>
        <argument name="provider" xsi:type="string">Magento\Catalog\Api\ProductRepositoryInterface</argument>
    </arguments>
</block>
```
