Skip to content

Commit

Permalink
[DOCS] Update range field type docs (elastic#62112) (elastic#62454)
Browse files Browse the repository at this point in the history
Co-authored-by: Wylie Conlon <[email protected]>
  • Loading branch information
jrodewig and Wylie Conlon authored Sep 16, 2020
1 parent f8634e5 commit 484e74c
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions docs/reference/mapping/types/range.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@
<titleabbrev>Range</titleabbrev>
++++

Range field types represent a continuous range of values between an upper and lower
bound. For example, a range can represent _any date in October_ or _any
integer from 0 to 9_. They are defined using the operators
`gt` or `gte` for the lower bound, and `lt` or `lte` for the upper bound.
They can be used for querying, and have
limited support for aggregations. The only supported aggregations are
{ref}/search-aggregations-bucket-histogram-aggregation.html[histogram],
{ref}/search-aggregations-metrics-cardinality-aggregation.html[cardinality].

The following range types are supported:

[horizontal]
`integer_range`:: A range of signed 32-bit integers with a minimum value of +-2^31^+ and maximum of +2^31^-1+.
`float_range`:: A range of single-precision 32-bit IEEE 754 floating point values.
`long_range`:: A range of signed 64-bit integers with a minimum value of +-2^63^+ and maximum of +2^63^-1+.
`double_range`:: A range of double-precision 64-bit IEEE 754 floating point values.
`date_range`:: A range of date values represented as unsigned 64-bit integer milliseconds elapsed since system epoch.
`date_range`:: A range of <<date,`date`>> values. Date ranges support various date formats
through the <<mapping-date-format,`format`>> mapping parameter. Regardless of
the format used, date values are parsed into an unsigned 64-bit integer
representing milliseconds since the Unix epoch in UTC. Values containing the
`now` <<date-math,date math>> expression are not supported.
`ip_range` :: A range of ip values supporting either {wikipedia}/IPv4[IPv4] or
{wikipedia}/IPv6[IPv6] (or mixed) addresses.

Expand Down Expand Up @@ -41,22 +54,22 @@ PUT range_index/_doc/1?refresh
{
"expected_attendees" : { <2>
"gte" : 10,
"lte" : 20
"lt" : 20
},
"time_frame" : { <3>
"gte" : "2015-10-31 12:00:00", <4>
"time_frame" : {
"gte" : "2015-10-31 12:00:00", <3>
"lte" : "2015-11-01"
}
}
--------------------------------------------------
// TESTSETUP

<1> `date_range` types accept the same field parameters defined by the <<date, `date`>> type.
<2> Example indexing a meeting with 10 to 20 attendees.
<3> Date ranges accept the same format as described in <<ranges-on-dates, date range queries>>.
<4> Example date range using date time stamp. This also accepts <<date-math, date math>> formatting. Note that "now" cannot be used at indexing time.
<2> Example indexing a meeting with 10 to 20 attendees, not including 20.
<3> Example date range using date time stamp.

The following is an example of a <<query-dsl-term-query, term query>> on the `integer_range` field named "expected_attendees".
12 is a value inside the range, so it will match.

[source,console]
--------------------------------------------------
Expand Down Expand Up @@ -99,7 +112,7 @@ The result produced by the above query.
"_score" : 1.0,
"_source" : {
"expected_attendees" : {
"gte" : 10, "lte" : 20
"gte" : 10, "lt" : 20
},
"time_frame" : {
"gte" : "2015-10-31 12:00:00", "lte" : "2015-11-01"
Expand Down Expand Up @@ -161,7 +174,7 @@ This query produces a similar result:
"_score" : 1.0,
"_source" : {
"expected_attendees" : {
"gte" : 10, "lte" : 20
"gte" : 10, "lt" : 20
},
"time_frame" : {
"gte" : "2015-10-31 12:00:00", "lte" : "2015-11-01"
Expand Down

0 comments on commit 484e74c

Please sign in to comment.