# ElasticSearch UI: Add filters on top of the search query

**URL:** <https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121>\
**Category:** Elastic Search\
**Created:** [September 25, 2024, 5:47pm UTC](https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121 "2024-09-25T17:47:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hiru\_Fernando](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hiru_fernando/32/137764_2.png) [@Hiru\_Fernando](https://discuss.elastic.co/u/Hiru_Fernando)\
**Post date:** [September 25, 2024, 5:47pm UTC](https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121/1 "2024-09-25T17:47:41Z")

</div>

Hi team,

Our team is using Elastic search UI functions including Elastic Search connector (setup like this [Elasticsearch Connector | Documentation](https://www.elastic.co/docs/current/search-ui/api/connectors/elasticsearch)) and SearchDriver (set up like this [Configuration | Documentation](https://www.elastic.co/docs/current/search-ui/api/core/configuration#search-query-queryconfig))  
On top of search query term, the user can also add filters to filter the search results even more.

The "filters" field in searchQuery (within the SearchDriver) only matches the exact value provided instead of a "contains".

We tried the following on the Elasticsearch console and it works great!

```auto
GET /my_index/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "tutorial"
          }
        },
        {
          "match": {
            "title": "install"
          }
        }
      ]
    }
  }
}

```

how can we replicate this exact behavior using searchDriver? Is it possible or is there another field we could use?

Thanks!!

---

<div class="post-metadata">

**Author:** ![James\_Williams](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_williams/32/137929_2.png) [@James\_Williams](https://discuss.elastic.co/u/James_Williams)\
**Post date:** [September 27, 2024, 6:13pm UTC](https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121/2 "2024-09-27T18:13:39Z")

</div>

Hiru,  
Have you attempted to customize the Elasticsearch request body yet? At the bottom of the ["Elastic Connector" documentation page](https://www.elastic.co/docs/current/search-ui/api/connectors/elasticsearch#customise-the-elasticsearch-request-body), there's a reference for how to customize the query options.

---

<div class="post-metadata">

**Author:** ![Hiru\_Fernando](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hiru_fernando/32/137764_2.png) [@Hiru\_Fernando](https://discuss.elastic.co/u/Hiru_Fernando)\
**Post date:** [September 27, 2024, 7:51pm UTC](https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121/3 "2024-09-27T19:51:19Z")

</div>

Hi James!

That actually ended up being the fix! Thank you for the suggestion!

This is what I basically did in the code when we are creating the API connector,  
I had to override query to include the following bool -\> should values that contains the "filter".  
This query allows us to filter on multiple filters on top of the search query.

```auto
GET /search-gitlab-docs-hugo/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "should": [
              {
                "term": {
                  "gitlab_docs_section": "tutorials"
                }
              }
            ]
          }
        }
      ],
      "minimum_should_match": 1
    }
  },
  "highlight": {
    "fields": {
      "body_content": {}
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 25, 2024, 7:51pm UTC](https://discuss.elastic.co/t/elasticsearch-ui-add-filters-on-top-of-the-search-query/367121/4 "2024-10-25T19:51:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
