Searching documents with nested fields, using "exists" filter?
See original GitHub issueI have a document similar to this:
class MyDoc(DocType):
field1 = String()
field2 = Nested(properties={"field3": String(), "field4: String()})
I would like to search for all documents that actually have field3
…
As a control, I have tried:
>>> s = MyDoc.search()
>>> s.filter("exists", field="field1").count()
>>> 26870
But, with the nested field, it doesn’t seem to work even though I know that there are such documents:
>>> s.filter("exists", field="field2").count()
>>> 0
>>> s.filter("exists", field="field2.field3").count()
>>> 0
>>> s.filter("exists", field="field2__field3").count()
>>> 0
So, my question is: how to search for documents that have a specified nested field? (Working with elasticsearch_dsl v0.0.5.dev0)
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
elastic exists query for nested documents
May 12, 2021 at 10:15. This query returns empty results for me.. Although in Discover mode I see documents with non-empty nested field....
Read more >Execute a filter on nested document only if it exists
I am using ES 2.3 and have a query in which filter section looks as follows: "filter": { "query": { "bool": { "must":...
Read more >Query on Embedded/Nested Documents
This page provides examples of query operations on embedded/nested documents using the db.collection.find() method in mongosh . The examples on this page ...
Read more >Nested - OpenSearch documentation
A nested field type is a special type of object field type. Any object field can take an array of objects. Each of...
Read more >Querying arrays with complex types and nested structures
To filter an array that includes a nested structure by one of its child elements, issue a query with an UNNEST operator. For...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I found it:
And now it works.
Thanks again for your help!
@osama-v8
Q()
serves the same purpose now