I am searching ES to find empty string field using "must_not" and exists as follows, but it returns "0" hits. After I change the query to "must" and exists I am getting all hits where the filed having empty value as follows. Any help!
so the exists query matches, if the field itself exists in the JSON document which is true in your result, as the field is clearly there.
You seem to search for data existing in this field - which is much harder, when data is being indexed. I'd try a different approach, and either remove that field at index time, when there is no data in, so that the exists query works,or add a another field (a boolean) like is_preferred_first_empty, that is true or false and also added on indexing.
if you do not want to change your ingestions mechanism, you can always use the ingest node functionality and a script processor to do this.
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.