# Search on relationship fields by default

By default, the search is performed only on the classic columns of your table and does not take into account the belongsTo fields.

You usually have the possibility to click on **`Try an extended search`** to extend the search to `belongsTo` fields in a second step.

![](http://g.recordit.co/edIvniKO9X.gif)

But you can as well extend Forest Admin's default routes to **use the extended search by default**.

## Requirements

* An admin backend running on forest-express-sequelize

## How it works

### Directory: /routes

This directory contains the `customers.js` file where the model is declared.

You will have to update the routes that get the `list` but also the `count` of customers.

{% code title="/routes/customers.js" %}

```javascript
...

// Get a list of Customers - Check out our documentation for more details: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#get-a-list-of-records
router.get('/customers', permissionMiddlewareCreator.list(), (request, response, next) => {
  request.query.searchExtended = '1';
  
  const recordsGetter = new RecordsGetter(customers, request.user, request.query);
  recordsGetter.getAll()
    .then(records => recordsGetter.serialize(records))
    .then(recordsSerialized => response.send(recordsSerialized))
    .catch(next);
});

// Get a number of Customers - Check out our documentation for more details: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#get-a-list-of-records
router.get('/customers/count', permissionMiddlewareCreator.list(), (request, response, next) => {
  request.query.searchExtended = '1';

  const recordsCounter = new RecordsCounter(customers, request.user, request.query);
  recordsCounter.count()
    .then(count => response.send({ count }))
    .catch(next);
});

...
```

{% endcode %}

With this snippet, only the `customers'`collection would use extended search by default.

{% hint style="warning" %}
Using extended search is less performant than default search. Use this wisely.
{% endhint %}


---

# 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/woodshop/how-tos/how-to-search-on-belongsto-relationship-fields-by-default.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.
