CONSOLE is the new AUTOSENSE
This commit is contained in:
parent
e486560ea8
commit
a865090cf3
|
@ -9,14 +9,14 @@ filter. Maps to Lucene `ConstantScoreQuery`.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"constant_score" : {
|
"constant_score" : {
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"term" : { "user" : "kimchy"}
|
"term" : { "user" : "kimchy"}
|
||||||
},
|
},
|
||||||
"boost" : 1.2
|
"boost" : 1.2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
|
@ -16,14 +16,14 @@ by the query.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"function_score": {
|
"function_score": {
|
||||||
"query": {},
|
"query": {},
|
||||||
"boost": "5",
|
"boost": "5",
|
||||||
"random_score": {}, <1>
|
"random_score": {}, <1>
|
||||||
"boost_mode":"multiply"
|
"boost_mode":"multiply"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -38,27 +38,27 @@ given filtering query
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"function_score": {
|
"function_score": {
|
||||||
"query": {},
|
"query": {},
|
||||||
"boost": "5", <1>
|
"boost": "5", <1>
|
||||||
"functions": [
|
"functions": [
|
||||||
{
|
{
|
||||||
"filter": {},
|
"filter": {},
|
||||||
"random_score": {}, <2>
|
"random_score": {}, <2>
|
||||||
"weight": 23
|
"weight": 23
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filter": {},
|
"filter": {},
|
||||||
"weight": 42
|
"weight": 42
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"max_boost": 42,
|
"max_boost": 42,
|
||||||
"score_mode": "max",
|
"score_mode": "max",
|
||||||
"boost_mode": "multiply",
|
"boost_mode": "multiply",
|
||||||
"min_score" : 42
|
"min_score" : 42
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -473,34 +473,34 @@ the request would look like this:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"function_score": {
|
"function_score": {
|
||||||
"functions": [
|
"functions": [
|
||||||
{
|
{
|
||||||
"gauss": {
|
"gauss": {
|
||||||
"price": {
|
"price": {
|
||||||
"origin": "0",
|
"origin": "0",
|
||||||
"scale": "20"
|
"scale": "20"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"gauss": {
|
||||||
|
"location": {
|
||||||
|
"origin": "11, 12",
|
||||||
|
"scale": "2km"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
},
|
"query": {
|
||||||
{
|
"match": {
|
||||||
"gauss": {
|
"properties": "balcony"
|
||||||
"location": {
|
|
||||||
"origin": "11, 12",
|
|
||||||
"scale": "2km"
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"score_mode": "multiply"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"query": {
|
|
||||||
"match": {
|
|
||||||
"properties": "balcony"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"score_mode": "multiply"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
|
@ -8,7 +8,7 @@ distance from a geo point. Assuming the following mapping:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /my_locations
|
PUT /my_locations
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"location": {
|
"location": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"pin": {
|
"pin": {
|
||||||
|
@ -51,22 +51,22 @@ filter:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my_locations/location/_search
|
GET /my_locations/location/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool" : {
|
||||||
"must" : {
|
"must" : {
|
||||||
"match_all" : {}
|
"match_all" : {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"geo_distance" : {
|
"geo_distance" : {
|
||||||
"distance" : "200km",
|
"distance" : "200km",
|
||||||
"pin.location" : {
|
"pin.location" : {
|
||||||
"lat" : 40,
|
"lat" : 40,
|
||||||
"lon" : -70
|
"lon" : -70
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -85,22 +85,22 @@ representation of the geo point, the filter can accept it as well:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my_locations/location/_search
|
GET /my_locations/location/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool" : {
|
||||||
"must" : {
|
"must" : {
|
||||||
"match_all" : {}
|
"match_all" : {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"geo_distance" : {
|
"geo_distance" : {
|
||||||
"distance" : "12km",
|
"distance" : "12km",
|
||||||
"pin.location" : {
|
"pin.location" : {
|
||||||
"lat" : 40,
|
"lat" : 40,
|
||||||
"lon" : -70
|
"lon" : -70
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -116,19 +116,19 @@ conform with http://geojson.org/[GeoJSON].
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my_locations/location/_search
|
GET /my_locations/location/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool" : {
|
||||||
"must" : {
|
"must" : {
|
||||||
"match_all" : {}
|
"match_all" : {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"geo_distance" : {
|
"geo_distance" : {
|
||||||
"distance" : "12km",
|
"distance" : "12km",
|
||||||
"pin.location" : [-70, 40]
|
"pin.location" : [-70, 40]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -144,19 +144,19 @@ Format in `lat,lon`.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my_locations/location/_search
|
GET /my_locations/location/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool" : {
|
||||||
"must" : {
|
"must" : {
|
||||||
"match_all" : {}
|
"match_all" : {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"geo_distance" : {
|
"geo_distance" : {
|
||||||
"distance" : "12km",
|
"distance" : "12km",
|
||||||
"pin.location" : "40,-70"
|
"pin.location" : "40,-70"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -169,19 +169,19 @@ GET /my_locations/location/_search
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my_locations/location/_search
|
GET /my_locations/location/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool" : {
|
||||||
"must" : {
|
"must" : {
|
||||||
"match_all" : {}
|
"match_all" : {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter" : {
|
||||||
"geo_distance" : {
|
"geo_distance" : {
|
||||||
"distance" : "12km",
|
"distance" : "12km",
|
||||||
"pin.location" : "drm3btev3e86"
|
"pin.location" : "drm3btev3e86"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
|
@ -7,24 +7,26 @@ of `1.0`.
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{ "query": {
|
{
|
||||||
"match_all": {}
|
"query": {
|
||||||
}
|
"match_all": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
The `_score` can be changed with the `boost` parameter:
|
The `_score` can be changed with the `boost` parameter:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{ "query": {
|
{
|
||||||
"match_all": { "boost" : 1.2 }
|
"query": {
|
||||||
}
|
"match_all": { "boost" : 1.2 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
[[query-dsl-match-none-query]]
|
[[query-dsl-match-none-query]]
|
||||||
[float]
|
[float]
|
||||||
|
@ -35,9 +37,10 @@ This is the inverse of the `match_all` query, which matches no documents.
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{ "query": {
|
{
|
||||||
"match_none": {}
|
"query": {
|
||||||
}
|
"match_none": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
|
@ -17,17 +17,17 @@ fields, limiting the number of selected terms to 12.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"more_like_this" : {
|
"more_like_this" : {
|
||||||
"fields" : ["title", "description"],
|
"fields" : ["title", "description"],
|
||||||
"like" : "Once upon a time",
|
"like" : "Once upon a time",
|
||||||
"min_term_freq" : 1,
|
"min_term_freq" : 1,
|
||||||
"max_query_terms" : 12
|
"max_query_terms" : 12
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
A more complicated use case consists of mixing texts with documents already
|
A more complicated use case consists of mixing texts with documents already
|
||||||
existing in the index. In this case, the syntax to specify a document is
|
existing in the index. In this case, the syntax to specify a document is
|
||||||
|
@ -37,29 +37,29 @@ similar to the one used in the <<docs-multi-get,Multi GET API>>.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"more_like_this" : {
|
"more_like_this" : {
|
||||||
"fields" : ["title", "description"],
|
"fields" : ["title", "description"],
|
||||||
"like" : [
|
"like" : [
|
||||||
{
|
{
|
||||||
"_index" : "imdb",
|
"_index" : "imdb",
|
||||||
"_type" : "movies",
|
"_type" : "movies",
|
||||||
"_id" : "1"
|
"_id" : "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "imdb",
|
"_index" : "imdb",
|
||||||
"_type" : "movies",
|
"_type" : "movies",
|
||||||
"_id" : "2"
|
"_id" : "2"
|
||||||
},
|
},
|
||||||
"and potentially some more text here as well"
|
"and potentially some more text here as well"
|
||||||
],
|
],
|
||||||
"min_term_freq" : 1,
|
"min_term_freq" : 1,
|
||||||
"max_query_terms" : 12
|
"max_query_terms" : 12
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
Finally, users can mix some texts, a chosen set of documents but also provide
|
Finally, users can mix some texts, a chosen set of documents but also provide
|
||||||
documents not necessarily present in the index. To provide documents not
|
documents not necessarily present in the index. To provide documents not
|
||||||
|
@ -69,34 +69,34 @@ present in the index, the syntax is similar to <<docs-termvectors-artificial-doc
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"more_like_this" : {
|
"more_like_this" : {
|
||||||
"fields" : ["name.first", "name.last"],
|
"fields" : ["name.first", "name.last"],
|
||||||
"like" : [
|
"like" : [
|
||||||
{
|
{
|
||||||
"_index" : "marvel",
|
"_index" : "marvel",
|
||||||
"_type" : "quotes",
|
"_type" : "quotes",
|
||||||
"doc" : {
|
"doc" : {
|
||||||
"name": {
|
"name": {
|
||||||
"first": "Ben",
|
"first": "Ben",
|
||||||
"last": "Grimm"
|
"last": "Grimm"
|
||||||
},
|
},
|
||||||
"tweet": "You got no idea what I'd... what I'd give to be invisible."
|
"tweet": "You got no idea what I'd... what I'd give to be invisible."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "marvel",
|
"_index" : "marvel",
|
||||||
"_type" : "quotes",
|
"_type" : "quotes",
|
||||||
"_id" : "2"
|
"_id" : "2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"min_term_freq" : 1,
|
||||||
|
"max_query_terms" : 12
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"min_term_freq" : 1,
|
|
||||||
"max_query_terms" : 12
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
==== How it Works
|
==== How it Works
|
||||||
|
|
||||||
|
@ -125,32 +125,32 @@ default, but there will be no speed up on analysis for these fields.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /imdb
|
PUT /imdb
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"movies": {
|
"movies": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"title": {
|
"title": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"term_vector": "yes"
|
"term_vector": "yes"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"type": "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"fields" : {
|
"fields" : {
|
||||||
"raw": {
|
"raw": {
|
||||||
"type" : "text",
|
"type" : "text",
|
||||||
"analyzer": "keyword",
|
"analyzer": "keyword",
|
||||||
"term_vector" : "yes"
|
"term_vector" : "yes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
==== Parameters
|
==== Parameters
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
<1> The query string.
|
<1> The query string.
|
||||||
<2> The fields to be queried.
|
<2> The fields to be queried.
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
<1> Query the `title`, `first_name` and `last_name` fields.
|
<1> Query the `title`, `first_name` and `last_name` fields.
|
||||||
|
|
||||||
Individual fields can be boosted with the caret (`^`) notation:
|
Individual fields can be boosted with the caret (`^`) notation:
|
||||||
|
@ -54,7 +54,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> The `subject` field is three times as important as the `message` field.
|
<1> The `subject` field is three times as important as the `message` field.
|
||||||
|
|
||||||
|
@ -98,16 +98,16 @@ find the single best matching field. For instance, this query:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "brown fox",
|
"query": "brown fox",
|
||||||
"type": "best_fields",
|
"type": "best_fields",
|
||||||
"fields": [ "subject", "message" ],
|
"fields": [ "subject", "message" ],
|
||||||
"tie_breaker": 0.3
|
"tie_breaker": 0.3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
would be executed as:
|
would be executed as:
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
Normally the `best_fields` type uses the score of the *single* best matching
|
Normally the `best_fields` type uses the score of the *single* best matching
|
||||||
field, but if `tie_breaker` is specified, then it calculates the score as
|
field, but if `tie_breaker` is specified, then it calculates the score as
|
||||||
|
@ -165,7 +165,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> All terms must be present.
|
<1> All terms must be present.
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
would be executed as:
|
would be executed as:
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
The score from each `match` clause is added together, then divided by the
|
The score from each `match` clause is added together, then divided by the
|
||||||
number of `match` clauses.
|
number of `match` clauses.
|
||||||
|
@ -249,15 +249,15 @@ This query:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "quick brown f",
|
"query": "quick brown f",
|
||||||
"type": "phrase_prefix",
|
"type": "phrase_prefix",
|
||||||
"fields": [ "subject", "message" ]
|
"fields": [ "subject", "message" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
would be executed as:
|
would be executed as:
|
||||||
|
|
||||||
|
@ -266,16 +266,16 @@ would be executed as:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"dis_max": {
|
"dis_max": {
|
||||||
"queries": [
|
"queries": [
|
||||||
{ "match_phrase_prefix": { "subject": "quick brown f" }},
|
{ "match_phrase_prefix": { "subject": "quick brown f" }},
|
||||||
{ "match_phrase_prefix": { "message": "quick brown f" }}
|
{ "match_phrase_prefix": { "message": "quick brown f" }}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
Also, accepts `analyzer`, `boost`, `slop` and `zero_terms_query` as explained
|
Also, accepts `analyzer`, `boost`, `slop` and `zero_terms_query` as explained
|
||||||
in <<query-dsl-match-query>>. Type `phrase_prefix` additionally accepts
|
in <<query-dsl-match-query>>. Type `phrase_prefix` additionally accepts
|
||||||
|
@ -326,16 +326,16 @@ A query like:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "Will Smith",
|
"query": "Will Smith",
|
||||||
"type": "cross_fields",
|
"type": "cross_fields",
|
||||||
"fields": [ "first_name", "last_name" ],
|
"fields": [ "first_name", "last_name" ],
|
||||||
"operator": "and"
|
"operator": "and"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
is executed as:
|
is executed as:
|
||||||
|
|
||||||
|
@ -386,18 +386,18 @@ both use an `edge_ngram` analyzer, this query:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "Jon",
|
"query": "Jon",
|
||||||
"type": "cross_fields",
|
"type": "cross_fields",
|
||||||
"fields": [
|
"fields": [
|
||||||
"first", "first.edge",
|
"first", "first.edge",
|
||||||
"last", "last.edge"
|
"last", "last.edge"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
would be executed as:
|
would be executed as:
|
||||||
|
|
||||||
|
@ -426,28 +426,28 @@ GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"should": [
|
"should": [
|
||||||
{
|
{
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "Will Smith",
|
"query": "Will Smith",
|
||||||
"type": "cross_fields",
|
"type": "cross_fields",
|
||||||
"fields": [ "first", "last" ],
|
"fields": [ "first", "last" ],
|
||||||
"minimum_should_match": "50%" <1>
|
"minimum_should_match": "50%" <1>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "Will Smith",
|
"query": "Will Smith",
|
||||||
"type": "cross_fields",
|
"type": "cross_fields",
|
||||||
"fields": [ "*.edge" ]
|
"fields": [ "*.edge" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> Either `will` or `smith` must be present in either of the `first`
|
<1> Either `will` or `smith` must be present in either of the `first`
|
||||||
or `last` fields
|
or `last` fields
|
||||||
|
@ -460,16 +460,16 @@ parameter in the query.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"multi_match" : {
|
"multi_match" : {
|
||||||
"query": "Jon",
|
"query": "Jon",
|
||||||
"type": "cross_fields",
|
"type": "cross_fields",
|
||||||
"analyzer": "standard", <1>
|
"analyzer": "standard", <1>
|
||||||
"fields": [ "first", "last", "*.edge" ]
|
"fields": [ "first", "last", "*.edge" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> Use the `standard` analyzer for all fields.
|
<1> Use the `standard` analyzer for all fields.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
A boost can also be associated with the query:
|
A boost can also be associated with the query:
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
Or :
|
Or :
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
This multi term query allows you to control how it gets rewritten using the
|
This multi term query allows you to control how it gets rewritten using the
|
||||||
<<query-dsl-multi-term-rewrite,rewrite>>
|
<<query-dsl-multi-term-rewrite,rewrite>>
|
||||||
|
|
|
@ -63,7 +63,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------
|
------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
<1> The `query` parameter indicates query context.
|
<1> The `query` parameter indicates query context.
|
||||||
<2> The `bool` and two `match` clauses are used in query context,
|
<2> The `bool` and two `match` clauses are used in query context,
|
||||||
which means that they are used to score how well each document
|
which means that they are used to score how well each document
|
||||||
|
|
|
@ -22,7 +22,7 @@ GET _search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
The `range` query accepts the following parameters:
|
The `range` query accepts the following parameters:
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ GET _search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
===== Date math and rounding
|
===== Date math and rounding
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ GET _search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
|
||||||
===== Time zone in range queries
|
===== Time zone in range queries
|
||||||
|
|
||||||
|
@ -117,8 +118,7 @@ accepts it), or it can be specified as the `time_zone` parameter:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _search
|
GET _search
|
||||||
{
|
{
|
||||||
"query":
|
"query": {
|
||||||
{
|
|
||||||
"range" : {
|
"range" : {
|
||||||
"timestamp" : {
|
"timestamp" : {
|
||||||
"gte": "2015-01-01 00:00:00", <1>
|
"gte": "2015-01-01 00:00:00", <1>
|
||||||
|
@ -129,6 +129,6 @@ GET _search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
<1> This date will be converted to `2014-12-31T23:00:00 UTC`.
|
<1> This date will be converted to `2014-12-31T23:00:00 UTC`.
|
||||||
<2> `now` is not affected by the `time_zone` parameter (dates must be stored as UTC).
|
<2> `now` is not affected by the `time_zone` parameter (dates must be stored as UTC).
|
||||||
|
|
|
@ -100,12 +100,12 @@ introduced fields included). For example:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"simple_query_string" : {
|
"simple_query_string" : {
|
||||||
"fields" : ["content", "name.*^5"],
|
"fields" : ["content", "name.*^5"],
|
||||||
"query" : "foo bar baz"
|
"query" : "foo bar baz"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
@ -120,12 +120,12 @@ should be enabled. It is specified as a `|`-delimited string with the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"simple_query_string" : {
|
"simple_query_string" : {
|
||||||
"query" : "foo | bar + baz*",
|
"query" : "foo | bar + baz*",
|
||||||
"flags" : "OR|AND|PREFIX"
|
"flags" : "OR|AND|PREFIX"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
|
@ -8,17 +8,17 @@ to Lucene `SpanFirstQuery`. Here is an example:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_first" : {
|
"span_first" : {
|
||||||
"match" : {
|
"match" : {
|
||||||
"span_term" : { "user" : "kimchy" }
|
"span_term" : { "user" : "kimchy" }
|
||||||
},
|
},
|
||||||
"end" : 3
|
"end" : 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
The `match` clause can be any other span type query. The `end` controls
|
The `match` clause can be any other span type query. The `end` controls
|
||||||
the maximum end position permitted in a match.
|
the maximum end position permitted in a match.
|
||||||
|
|
|
@ -8,15 +8,15 @@ Matches the union of its span clauses. The span or query maps to Lucene
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_or" : {
|
"span_or" : {
|
||||||
"clauses" : [
|
"clauses" : [
|
||||||
{ "span_term" : { "field" : "value1" } },
|
{ "span_term" : { "field" : "value1" } },
|
||||||
{ "span_term" : { "field" : "value2" } },
|
{ "span_term" : { "field" : "value2" } },
|
||||||
{ "span_term" : { "field" : "value3" } }
|
{ "span_term" : { "field" : "value3" } }
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
|
@ -20,7 +20,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
The above request is translated into:
|
The above request is translated into:
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
Alternatively passing the template as an escaped string works as well:
|
Alternatively passing the template as an escaped string works as well:
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> New line characters (`\n`) should be escaped as `\\n` or removed,
|
<1> New line characters (`\n`) should be escaped as `\\n` or removed,
|
||||||
and quotes (`"`) should be escaped as `\\"`.
|
and quotes (`"`) should be escaped as `\\"`.
|
||||||
|
@ -79,7 +79,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
<1> Name of the query template in `config/scripts/`, i.e., `my_template.mustache`.
|
<1> Name of the query template in `config/scripts/`, i.e., `my_template.mustache`.
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ PUT /_search/template/my_template
|
||||||
"template": { "match": { "text": "{{query_string}}" }}
|
"template": { "match": { "text": "{{query_string}}" }}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
||||||
and refer to it in the `template` query with the `id` parameter:
|
and refer to it in the `template` query with the `id` parameter:
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
||||||
<1> Name of the query template in `config/scripts/`, i.e., `my_template.mustache`.
|
<1> Name of the query template in `config/scripts/`, i.e., `my_template.mustache`.
|
||||||
|
|
|
@ -7,11 +7,11 @@ Filters documents matching the provided document / mapping type.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"type" : {
|
"type" : {
|
||||||
"value" : "my_type"
|
"value" : "my_type"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// AUTOSENSE
|
// CONSOLE
|
||||||
|
|
Loading…
Reference in New Issue