I have a _search query running that checks certain properties and aggregates values based on the search. One of the search criteria is:
{ "term": { "Status": 0} }
"Status" was a property added after documents were already indexed. By default, I treat Status = 0. So I'm trying to search for documents where Status = 0 OR the property doesn't exist in which case I want to treat as 0 anyways.
Is there a way to structure my search query to handle this? Or possibly set a default value when adding a new property to a mapping?
This is not search, this is full index scan. If you want to implement it as a search you can combine together your term query with exists query, using bool query.
@Igor_Motov Hmmm...ok. Can you elaborate a little on that? I couldn't figure out how to have an OR using the bool query. Here is the full example of what I'm trying to accomplish. I want to find all documents with a CloseDate = '2018-02-01' and Status = 0. But documents that were indexed prior to adding Status don't have that property. So currently it's filtering those documents out
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.