Documents applicability of term query to range type (#28166)

Closes #27030
This commit is contained in:
David Kemp 2018-01-19 09:19:01 +11:00 committed by Mayya Sharipova
parent 19a2b01e43
commit 531c58cf81
2 changed files with 66 additions and 7 deletions

View File

@ -47,18 +47,16 @@ PUT range_index/_doc/1
--------------------------------------------------
//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]
--------------------------------------------------
POST range_index/_search
GET range_index/_search
{
"query" : {
"range" : {
"time_frame" : { <5>
"gte" : "2015-10-31",
"lte" : "2015-11-01",
"relation" : "within" <6>
"term" : {
"expected_attendees" : {
"value": 12
}
}
}
@ -104,6 +102,27 @@ The result produced by the above query.
--------------------------------------------------
// 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.
<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>>.
@ -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`,
`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]]
==== Parameters for range fields

View File

@ -51,6 +51,8 @@ GET _search
as the query clause for `normal`.
<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?
**************************************************