Adding filter to elastic search query


Like filters are available for query results and visualizations for SQL queries. E-G : SELECT action AS “action::filter”, COUNT (0) AS “actions count”
FROM events
GROUP BY action

Can you please let me know, whether the same is possible using elastic search query or not ?


If ElasticSearch queries support renaming output fields, then you can use filters by renaming the fields to have the ::filter or __filter suffix.


Hello Arik, can you please elaborate. Our scenario is,

“index”: “game_code”,
“aggs”: {
“Name”: {
“terms”: {
“field”: “player_name”

        "aggs": {
    "Country": {  "filter" : {
              "bool" : {
  "should" : {
    "term" : { "Country" : "{{Select the country name}}"}} }
        "aggs": {
            "Team": {
                "terms": {
                    "field": "team_name"

When this code is executed, according to country name we type in the text box, the player names and their team names will be displayed.
The output is

In this execution, in the textbox, the country name must be manually typed.
But our desired output is , the country names must be displayed as dropdown list rather than manual typing. Like this

Can you guide us wherein the change must be made in code, so as the receive the desired output ?


Arik, we are waiting for your reply, it’s quite urgent.


You need to rename the fields in the output to include the __filter or __multiFilter suffix. There are different ways to achieve this depends on your Elastic Search version and configuration.


I have a similar requirement. I couldn’t find something like this in elasticsearch .
Can you please point me to some resources where I can get some hint how to achieve this.