WARNING: Version 0.90 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Numeric Range Filter
editNumeric Range Filter
editDeprecated in 0.90.8.
Use the range filter with the fielddata
execution mode instead
Filters documents with fields that have values within a certain numeric range. Similar to range filter, except that it works only with numeric values, and the filter execution works differently.
{ "constant_score" : { "filter" : { "numeric_range" : { "age" : { "gte": 10, "lte": 20 } } } } }
The numeric range filter works by loading all the relevant field values into memory, and checking for the relevant docs if they satisfy the range requirements. This requires more memory since the numeric range data are loaded to memory, but can provide a significant increase in performance. Note, if the relevant field values have already been loaded to memory, for example because it was used in facets or was sorted on, then this filter should be used.
The numeric_range
filter accepts the following parameters:
|
Greater-than or equal to |
|
Greater-than |
|
Less-than or equal to |
|
Less-than |
Deprecated in 0.90.4.
The from
, to
, include_lower
and include_upper
parameters have been deprecated in favour of gt
,gte
,lt
,lte
Caching
editThe result of the filter is not cached by default. The _cache
can be
set to true
to cache the result of the filter. This is handy when
the same points parameters are used on several (many) other queries.
Note, the process of caching the first execution is higher when caching
(since it needs to satisfy different queries).
If caching the result of the filter is desired (for example, using the same "teen" filter with ages between 10 and 20), then it is advisable to simply use the range filter.
If the now
date math expression is used without rounding then a range numeric filter will never be cached even
if _cache
is set to true
. Also any filter that wraps this filter will never be cached.