Nested queries don't work as documented

Hello,

As documented in your documentation here, the documentation shows using dot-notation to traverse a nested field (user -> id). However, when using the query dsl this way, no results are returned.

Instead, you must use the nested query DSL structure in order to perform terms queries on nested fields.

Examples
Does Not work as documented

{
    "query": {
         "terms": {
               "foo.object_id": [
                    "obj.lvu3r6PlxWwiSWuU"
                ]
           }
      }
 }

** Works using nested DSL **

{
    "query": {
        "nested": {
            "path": "foo",
            "query": {
                "terms": {
                    "foo.object_id": [
                        "obj.lvu3r6PlxWwiSWuU"
                    ]
                }
            }
        }
   }
}

I have seen the other threads where Elastic folks have confirmed you have to used the nested DSL, but my question is ..... why do you have a documented example on the latest release that shows otherwise?

Is this a bug or is your documentation just wrong/confusing?

If its just confusing, then I would love to know the easiest way to submit documentation change requests that actually get processed in a timely manner.

I think it's easy for folks that live and breath Elasticsearch to just "know" this was a documentation issue, but for newcomers this wastes a ton of valuable time. Especially with dot-notation being so prolific in many/most top-5 popular programming languages.

Thanks for any feedback/help here.

Nested documents should be queried with nested query
Please refer to
Nested query | Elasticsearch Guide [7.13] | Elastic
Nested field type | Elasticsearch Guide [7.13] | Elastic

The documentation for the terms query with the dot notation happens to show querying a sub property of an object. Objects aren’t always mapped as ‘nested’ unless there’s a particular need to do so.

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