Documents applicability of term query to range type (#28166)
Closes #27030
This commit is contained in:
parent
19a2b01e43
commit
531c58cf81
|
@ -47,18 +47,16 @@ PUT range_index/_doc/1
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
//CONSOLE
|
//CONSOLE
|
||||||
|
|
||||||
The following is an example of a `date_range` query over the `date_range` field named "time_frame".
|
The following is an example of a <<query-dsl-term-query, term query>> on the `integer_range` field named "expected_attendees".
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST range_index/_search
|
GET range_index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"range" : {
|
"term" : {
|
||||||
"time_frame" : { <5>
|
"expected_attendees" : {
|
||||||
"gte" : "2015-10-31",
|
"value": 12
|
||||||
"lte" : "2015-11-01",
|
|
||||||
"relation" : "within" <6>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +102,27 @@ The result produced by the above query.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"took": 13/"took" : $body.took/]
|
// TESTRESPONSE[s/"took": 13/"took" : $body.took/]
|
||||||
|
|
||||||
|
|
||||||
|
The following is an example of a `date_range` query over the `date_range` field named "time_frame".
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
GET range_index/_search
|
||||||
|
{
|
||||||
|
"query" : {
|
||||||
|
"range" : {
|
||||||
|
"time_frame" : { <5>
|
||||||
|
"gte" : "2015-10-31",
|
||||||
|
"lte" : "2015-11-01",
|
||||||
|
"relation" : "within" <6>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:range_index]
|
||||||
|
|
||||||
<1> `date_range` types accept the same field parameters defined by the <<date, `date`>> type.
|
<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.
|
<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>>.
|
<3> Date ranges accept the same format as described in <<ranges-on-dates, date range queries>>.
|
||||||
|
@ -112,6 +131,44 @@ The result produced by the above query.
|
||||||
<6> Range queries over range <<mapping-types, fields>> support a `relation` parameter which can be one of `WITHIN`, `CONTAINS`,
|
<6> Range queries over range <<mapping-types, fields>> support a `relation` parameter which can be one of `WITHIN`, `CONTAINS`,
|
||||||
`INTERSECTS` (default).
|
`INTERSECTS` (default).
|
||||||
|
|
||||||
|
This query produces a similar result:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"took": 13,
|
||||||
|
"timed_out": false,
|
||||||
|
"_shards" : {
|
||||||
|
"total": 2,
|
||||||
|
"successful": 2,
|
||||||
|
"skipped" : 0,
|
||||||
|
"failed": 0
|
||||||
|
},
|
||||||
|
"hits" : {
|
||||||
|
"total" : 1,
|
||||||
|
"max_score" : 1.0,
|
||||||
|
"hits" : [
|
||||||
|
{
|
||||||
|
"_index" : "range_index",
|
||||||
|
"_type" : "_doc",
|
||||||
|
"_id" : "1",
|
||||||
|
"_score" : 1.0,
|
||||||
|
"_source" : {
|
||||||
|
"expected_attendees" : {
|
||||||
|
"gte" : 10, "lte" : 20
|
||||||
|
},
|
||||||
|
"time_frame" : {
|
||||||
|
"gte" : "2015-10-31 12:00:00", "lte" : "2015-11-01"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/"took": 13/"took" : $body.took/]
|
||||||
|
|
||||||
|
|
||||||
[[range-params]]
|
[[range-params]]
|
||||||
==== Parameters for range fields
|
==== Parameters for range fields
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ GET _search
|
||||||
as the query clause for `normal`.
|
as the query clause for `normal`.
|
||||||
<2> The `normal` clause has the default neutral boost of `1.0`.
|
<2> The `normal` clause has the default neutral boost of `1.0`.
|
||||||
|
|
||||||
|
A `term` query can also match against <<range, range data types>>.
|
||||||
|
|
||||||
.Why doesn't the `term` query match my document?
|
.Why doesn't the `term` query match my document?
|
||||||
**************************************************
|
**************************************************
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue