Reputation: 113
I am using range filters in elasticsearch with different options like
"date" : { "gte" : "now-1d" }
"date" : { "gte" : "now-1y" }
(it depends on the value of an variable)
Is it possible to define a keyword to accept all kinds of date, even if there is no field date?
Maybe something like:
"date" : { "gte" : _all }
Upvotes: 0
Views: 29
Reputation: 116
Have you tried using "exists"? https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html You should be able to combine two filters with bool - should /should not and filter on date gte nnnn OR not exists field: date (I'm assuming you want to filter on date range if you have a date, and include results where the date is missing as well)
Upvotes: 1