ElasticSearch Aggregation Query possible? ElasticSearch Aggregation Query possible? elasticsearch elasticsearch

ElasticSearch Aggregation Query possible?


maybe something like this (not sure about the nesting books.field):

{    "query" : {        "match_all" : {  }    },    "facets" : {        "filter_one" : {            "filter" : {                "and" : [                        {"filter" : {"term" : { "gender_id" : 1 }},                        {"filter" : {"term" : { "books.b_id" : 2065 }},                ]            }        },        "book_cnt" : {          "terms" : {                "field" : "books.b_name",                "size" : 5            }        }    }}


Thanks @mconlin for the hint. The query I got it working is the following:

{    "query": {        "filtered": {            "filter": {                "and" : [                    { "term": { "gender_id": 1 } },                    { "term": { "books.b_id": 2065} }                ]            }        }    },    "facets": {        "book_cnt": {            "terms": {                "field": "books.b_id",                "size": 5            }        }    }}

Turns out it's better to use the filter in the query itself instead of as a separate facet.