Elasticsearch 8.5 scenarios to Filter on Keyword Fields Within Nested Documents Using Multi-Index Query
I'm prototyping a solution and I've been struggling with this for a few days now and could really use some help. I'm trying to run a multi-index query in Elasticsearch 8.5 that filters on a keyword field within nested documents. However, I'm getting an unexpected `nested query` behavior that states `nested path not found`. It seems like my query is not correctly referencing the nested structure. Here’s the setup: I have two indices, `products` and `categories`. In the `products` index, there's a nested field called `specs` which has a `name` field of type `keyword`. I want to filter products based on a specific `specs.name`. Here’s my current query: ```json { "query": { "bool": { "must": [ { "nested": { "path": "specs", "query": { "term": { "specs.name": "Waterproof" } } } } ], "filter": { "term": { "category_id": "123" } } } } } ``` I’ve already checked my mappings and they look fine; the `specs` field is correctly defined as `nested`. To further troubleshoot, I ran a simple query directly on the `products` index and got results, but the nested filtering fails with the above behavior. I also tried switching the `nested path` to `specs` in case there was a typo, but that didn’t help either. Could this be an scenario related to how I’ve structured the indices? Or is there something inherently wrong with the nested query itself? I’ve also examined the Elasticsearch logs for any further insight but didn’t find anything relevant. Any suggestions would be appreciated! Any help would be greatly appreciated! I'd really appreciate any guidance on this.