Hi, I have nested property in my index document. I want to find all documents where nested field is blank.
example: I am indexing below document, how can I search for document where contact is not available ?
When dealing with null values "The first tool in your arsenal is the exists filter. This filter will return documents that have any value in the specified field. [...] The missing filter is essentially the inverse of exists: it returns documents where there is no value for a particular field. [...] The exists and missing filters also work on inner objects, not just core types."
DELETE index
PUT index/type/1 {
"Name": "John", "contact": [{"office": "1234", "home":"2345" }]
}
PUT index/type/2 {
"Name": "Tom"
}
GET index/_search {
"query": {
"missing" : { "field" : "contact" }
}
}
@mainec, I have tried with missing and its working fine if field is normal field. In my case contact in nested property, when I try the same query, its giving all records. Below is the query I am using, Am I doing anything wrong ?
I see - I naively assumed you were simply putting the document you supplied to the index and relied on automatic mappings. Seems like you supplied an explicit mapping beforehand then, right?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.