How to perform a filtered search in ElasticSearch in a sub-object field? For example, my document has a field idand data, which is a JSON array, as the data was stored in my database:
{_id: 000, merchant: "merchant_1", email: "hello@email.com"}
My search query:
"query": {
"filtered": {
"filter": { "term": { "data.merchant": "merchant_1"} },
"query": {
"query_string": {"query": "hello"} }
}
}
}
returns nothing, but executing a query using query_string helloreturns the correct rows. Change "data.merchant"=> "merchant"also does not change anything.
Am I doing something wrong here?
Update: . In the end, I just used a logical query that worked.
source
share