How to aggregate on the same field:value which are specified in query in elasticsearch

So my data in elasticsearch looks like this one whole dict with one person id is equal to one doc and it contains list of objects like {"dummy_name": "abc","dummy_id": "44850642"}which is shown below ,the thing is I am querying on the field dummy_id and I am getting result as some no. of matching query results, and I want to aggregate the on dummy_id field so I'll get no of docs for a specific dummy_name, but what happening is I am also getting the buckets of dummy_id which are not mentioned in the query its self as person contains list of objects in which dummy_id is present. {
"person_id": 1234,
"Properties": {
"Property1": [
{
"dummy_name": "abc",
"dummy_id": "44850642"
},
{},
{}
]
}
},
{"person_id": 1235,
...
...
...
}

Query I am using: {
"query": {
"bool": {
"must": [
{
"match": {
"Properties.Property1.concept_id": "453041 23234324 124324 "
}
}
]
}
},
"aggregations": {
"group_by_concept": {
"terms": {
"field": "Properties.Property1.concept_id",
"order": {
"_count": "desc"
},
"size": 10
}
}
}
}

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