Range filter with nil value

(Ramya Venkatesh) #1

I'm using the range filter like this for my application (Ignore the syntax)-
{:range {:created_at {:gte "from_date"
:lte "to_date"}}}

In some cases one of the dates can be "nil". I'm getting the correct results with the above query, but was wondering if the performance would be better if I split this to be something like-
{:range {:created_at
(if (nil? "from_date") {:lte "to_date"})
(if (nil? "to_date") {:gte "from_date"}
(else {:gte "from_date"
:lte "to_date"})}}

(Christoph) #2

On the Elasticsearch side it does not make any difference whether you set lte/gte to null or ommit it. I'm not sure if this is also true for the client you are using. Which language client is this? I doubt it makes a difference.

(Ramya Venkatesh) #3

Thanks Christoph. This is in Clojure, modified slightly here. I only wanted to know if cleaning the map for nil values makes sense at all, I guess not.

(system) #4