I am trying to have a cardinality aggregation on top of query_string. I am new to Elastic search and have hit some errors.
Each document looks something like this -
{
name: 'Jon Doe'
customId: 'x123yz'
prevAddressMap : {'NY':'2nd St', 'DC':'1st St', 'Chicago':'1st St' ... }
},
{ ...
},
.....
I have the query to get all the records I need -
{'query':{'query_string':{'fields':['prevAddressMap.*'],'query': '1st St'}}}
I want to count all the records with unique names. So, I tried using cardinality for it -
{
"query": {
"query_string": {
"fields": [
"prevAddressMap.*"
],
"query": "1st St"
}
},
"aggs": {
"distinct_count": {
"filter": {
"query": {
"query_string": {
"fields": [
"prevAddressMap.*"
],
"query": "1st St"
}
}
},
"aggs": {
"snapId_count": {
"cardinality": {
"field": "customId"
}
}
}
}
}
}
The error I am getting is -
elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', 'no [query] registered for [query]')
Can someone help me with this?