parent
606b7ea139
commit
b302b09b85
|
@ -145,12 +145,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
----
|
----
|
||||||
PUT sample_example
|
PUT sample_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_sample_analyzer" : {
|
"my_sample_analyzer": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["sample"]
|
"filter": [ "sample" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,18 +212,18 @@ For example, the following request creates a custom `sample` filter with
|
||||||
----
|
----
|
||||||
PUT sample_example
|
PUT sample_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_custom_analyzer" : {
|
"my_custom_analyzer": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["my_custom_sample_token_filter"]
|
"filter": [ "my_custom_sample_token_filter" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_custom_sample_token_filter" : {
|
"my_custom_sample_token_filter": {
|
||||||
"type" : "sample",
|
"type": "sample",
|
||||||
"foo" : true
|
"foo": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,12 +77,12 @@ apostrophe token filter to configure a new
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /apostrophe_example
|
PUT /apostrophe_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"standard_apostrophe" : {
|
"standard_apostrophe": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["apostrophe"]
|
"filter": [ "apostrophe" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,12 +83,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /asciifold_example
|
PUT /asciifold_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"standard_asciifolding" : {
|
"standard_asciifolding": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["asciifolding"]
|
"filter": [ "asciifolding" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,18 +118,18 @@ For example, the following request creates a custom `asciifolding` filter with
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /asciifold_example
|
PUT /asciifold_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"standard_asciifolding" : {
|
"standard_asciifolding": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["my_ascii_folding"]
|
"filter": [ "my_ascii_folding" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_ascii_folding" : {
|
"my_ascii_folding": {
|
||||||
"type" : "asciifolding",
|
"type": "asciifolding",
|
||||||
"preserve_original" : true
|
"preserve_original": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,12 +126,12 @@ CJK bigram token filter to configure a new
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /cjk_bigram_example
|
PUT /cjk_bigram_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"standard_cjk_bigram" : {
|
"standard_cjk_bigram": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["cjk_bigram"]
|
"filter": [ "cjk_bigram" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,23 +176,23 @@ parameters.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /cjk_bigram_example
|
PUT /cjk_bigram_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"han_bigrams" : {
|
"han_bigrams": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["han_bigrams_filter"]
|
"filter": [ "han_bigrams_filter" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"han_bigrams_filter" : {
|
"han_bigrams_filter": {
|
||||||
"type" : "cjk_bigram",
|
"type": "cjk_bigram",
|
||||||
"ignored_scripts": [
|
"ignored_scripts": [
|
||||||
"hangul",
|
"hangul",
|
||||||
"hiragana",
|
"hiragana",
|
||||||
"katakana"
|
"katakana"
|
||||||
],
|
],
|
||||||
"output_unigrams" : true
|
"output_unigrams": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,12 @@ CJK width token filter to configure a new
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /cjk_width_example
|
PUT /cjk_width_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"standard_cjk_width" : {
|
"standard_cjk_width": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["cjk_width"]
|
"filter": [ "cjk_width" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,12 +132,12 @@ classic token filter to configure a new
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /classic_example
|
PUT /classic_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"classic_analyzer" : {
|
"classic_analyzer": {
|
||||||
"tokenizer" : "classic",
|
"tokenizer": "classic",
|
||||||
"filter" : ["classic"]
|
"filter": [ "classic" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,13 +131,13 @@ PUT /common_grams_example
|
||||||
"analyzer": {
|
"analyzer": {
|
||||||
"index_grams": {
|
"index_grams": {
|
||||||
"tokenizer": "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter": ["common_grams"]
|
"filter": [ "common_grams" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"common_grams": {
|
"common_grams": {
|
||||||
"type": "common_grams",
|
"type": "common_grams",
|
||||||
"common_words": ["a", "is", "the"]
|
"common_words": [ "a", "is", "the" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,13 +211,13 @@ PUT /common_grams_example
|
||||||
"analyzer": {
|
"analyzer": {
|
||||||
"index_grams": {
|
"index_grams": {
|
||||||
"tokenizer": "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter": ["common_grams_query"]
|
"filter": [ "common_grams_query" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"common_grams_query": {
|
"common_grams_query": {
|
||||||
"type": "common_grams",
|
"type": "common_grams",
|
||||||
"common_words": ["a", "is", "the"],
|
"common_words": [ "a", "is", "the" ],
|
||||||
"ignore_case": true,
|
"ignore_case": true,
|
||||||
"query_mode": true
|
"query_mode": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /decimal_digit_example
|
PUT /decimal_digit_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"whitespace_decimal_digit" : {
|
"whitespace_decimal_digit": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["decimal_digit"]
|
"filter": [ "decimal_digit" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,12 +96,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /elision_example
|
PUT /elision_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"whitespace_elision" : {
|
"whitespace_elision": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["elision"]
|
"filter": [ "elision" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,18 +165,18 @@ and `j'` elisions:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /elision_case_sensitive_example
|
PUT /elision_case_sensitive_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"default" : {
|
"default": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["elision_case_sensitive"]
|
"filter": [ "elision_case_sensitive" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"elision_case_sensitive" : {
|
"elision_case_sensitive": {
|
||||||
"type" : "elision",
|
"type": "elision",
|
||||||
"articles" : ["l", "m", "t", "qu", "n", "s", "j"],
|
"articles": [ "l", "m", "t", "qu", "n", "s", "j" ],
|
||||||
"articles_case": true
|
"articles_case": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,12 +82,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT lowercase_example
|
PUT lowercase_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"whitespace_lowercase" : {
|
"whitespace_lowercase": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["lowercase"]
|
"filter": [ "lowercase" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,18 +36,18 @@ You can set it up like:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /multiplexer_example
|
PUT /multiplexer_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_analyzer" : {
|
"my_analyzer": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : [ "my_multiplexer" ]
|
"filter": [ "my_multiplexer" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_multiplexer" : {
|
"my_multiplexer": {
|
||||||
"type" : "multiplexer",
|
"type": "multiplexer",
|
||||||
"filters" : [ "lowercase", "lowercase, porter_stem" ]
|
"filters": [ "lowercase", "lowercase, porter_stem" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,17 @@ For example:
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_analyzer" : {
|
"my_analyzer": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["lowercase", "my_snow"]
|
"filter": [ "lowercase", "my_snow" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_snow" : {
|
"my_snow": {
|
||||||
"type" : "snowball",
|
"type": "snowball",
|
||||||
"language" : "Lovins"
|
"language": "Lovins"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,17 +26,17 @@ Here is an example:
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_analyzer" : {
|
"my_analyzer": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["lowercase", "custom_stems", "porter_stem"]
|
"filter": [ "lowercase", "custom_stems", "porter_stem" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"custom_stems" : {
|
"custom_stems": {
|
||||||
"type" : "stemmer_override",
|
"type": "stemmer_override",
|
||||||
"rules_path" : "analysis/stemmer_override.txt"
|
"rules_path": "analysis/stemmer_override.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,17 +58,17 @@ You can also define the overrides rules inline:
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_analyzer" : {
|
"my_analyzer": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["lowercase", "custom_stems", "porter_stem"]
|
"filter": [ "lowercase", "custom_stems", "porter_stem" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"custom_stems" : {
|
"custom_stems": {
|
||||||
"type" : "stemmer_override",
|
"type": "stemmer_override",
|
||||||
"rules" : [
|
"rules": [
|
||||||
"running, runs => run",
|
"running, runs => run",
|
||||||
"stemmer => stemmer"
|
"stemmer => stemmer"
|
||||||
]
|
]
|
||||||
|
|
|
@ -27,18 +27,18 @@ Here is an example:
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"search_synonyms" : {
|
"search_synonyms": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["graph_synonyms"]
|
"filter": [ "graph_synonyms" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"graph_synonyms" : {
|
"graph_synonyms": {
|
||||||
"type" : "synonym_graph",
|
"type": "synonym_graph",
|
||||||
"synonyms_path" : "analysis/synonym.txt"
|
"synonyms_path": "analysis/synonym.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,23 +62,23 @@ to note that only those synonym rules which cannot get parsed are ignored. For i
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["my_stop", "synonym_graph"]
|
"filter": [ "my_stop", "synonym_graph" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_stop": {
|
"my_stop": {
|
||||||
"type" : "stop",
|
"type": "stop",
|
||||||
"stopwords": ["bar"]
|
"stopwords": [ "bar" ]
|
||||||
},
|
},
|
||||||
"synonym_graph" : {
|
"synonym_graph": {
|
||||||
"type" : "synonym_graph",
|
"type": "synonym_graph",
|
||||||
"lenient": true,
|
"lenient": true,
|
||||||
"synonyms" : ["foo, bar => baz"]
|
"synonyms": [ "foo, bar => baz" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,12 +122,12 @@ configuration file (note use of `synonyms` instead of `synonyms_path`):
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym_graph",
|
"type": "synonym_graph",
|
||||||
"synonyms" : [
|
"synonyms": [
|
||||||
"lol, laughing out loud",
|
"lol, laughing out loud",
|
||||||
"universe, cosmos"
|
"universe, cosmos"
|
||||||
]
|
]
|
||||||
|
@ -153,13 +153,13 @@ declared using `format`:
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym_graph",
|
"type": "synonym_graph",
|
||||||
"format" : "wordnet",
|
"format": "wordnet",
|
||||||
"synonyms" : [
|
"synonyms": [
|
||||||
"s(100000001,1,'abstain',v,1,0).",
|
"s(100000001,1,'abstain',v,1,0).",
|
||||||
"s(100000001,2,'refrain',v,1,0).",
|
"s(100000001,2,'refrain',v,1,0).",
|
||||||
"s(100000001,3,'desist',v,1,0)."
|
"s(100000001,3,'desist',v,1,0)."
|
||||||
|
|
|
@ -13,18 +13,18 @@ Here is an example:
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["synonym"]
|
"filter": [ "synonym" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym",
|
"type": "synonym",
|
||||||
"synonyms_path" : "analysis/synonym.txt"
|
"synonyms_path": "analysis/synonym.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,23 +52,23 @@ to note that only those synonym rules which cannot get parsed are ignored. For i
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"tokenizer" : "standard",
|
"tokenizer": "standard",
|
||||||
"filter" : ["my_stop", "synonym"]
|
"filter": [ "my_stop", "synonym" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"my_stop": {
|
"my_stop": {
|
||||||
"type" : "stop",
|
"type": "stop",
|
||||||
"stopwords": ["bar"]
|
"stopwords": [ "bar" ]
|
||||||
},
|
},
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym",
|
"type": "synonym",
|
||||||
"lenient": true,
|
"lenient": true,
|
||||||
"synonyms" : ["foo, bar => baz"]
|
"synonyms": [ "foo, bar => baz" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,12 +113,12 @@ configuration file (note use of `synonyms` instead of `synonyms_path`):
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym",
|
"type": "synonym",
|
||||||
"synonyms" : [
|
"synonyms": [
|
||||||
"i-pod, i pod => ipod",
|
"i-pod, i pod => ipod",
|
||||||
"universe, cosmos"
|
"universe, cosmos"
|
||||||
]
|
]
|
||||||
|
@ -144,13 +144,13 @@ declared using `format`:
|
||||||
PUT /test_index
|
PUT /test_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym",
|
"type": "synonym",
|
||||||
"format" : "wordnet",
|
"format": "wordnet",
|
||||||
"synonyms" : [
|
"synonyms": [
|
||||||
"s(100000001,1,'abstain',v,1,0).",
|
"s(100000001,1,'abstain',v,1,0).",
|
||||||
"s(100000001,2,'refrain',v,1,0).",
|
"s(100000001,2,'refrain',v,1,0).",
|
||||||
"s(100000001,3,'desist',v,1,0)."
|
"s(100000001,3,'desist',v,1,0)."
|
||||||
|
|
|
@ -92,12 +92,12 @@ The following <<indices-create-index,create index API>> request uses the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT uppercase_example
|
PUT uppercase_example
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"whitespace_uppercase" : {
|
"whitespace_uppercase": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["uppercase"]
|
"filter": [ "uppercase" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,23 +145,23 @@ If the follower index is `active`, the API returns the following results:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"follower_indices" : [
|
"follower_indices": [
|
||||||
{
|
{
|
||||||
"follower_index" : "follower_index",
|
"follower_index": "follower_index",
|
||||||
"remote_cluster" : "remote_cluster",
|
"remote_cluster": "remote_cluster",
|
||||||
"leader_index" : "leader_index",
|
"leader_index": "leader_index",
|
||||||
"status" : "active",
|
"status": "active",
|
||||||
"parameters" : {
|
"parameters": {
|
||||||
"max_read_request_operation_count" : 5120,
|
"max_read_request_operation_count": 5120,
|
||||||
"max_read_request_size" : "32mb",
|
"max_read_request_size": "32mb",
|
||||||
"max_outstanding_read_requests" : 12,
|
"max_outstanding_read_requests": 12,
|
||||||
"max_write_request_operation_count" : 5120,
|
"max_write_request_operation_count": 5120,
|
||||||
"max_write_request_size" : "9223372036854775807b",
|
"max_write_request_size": "9223372036854775807b",
|
||||||
"max_outstanding_write_requests" : 9,
|
"max_outstanding_write_requests": 9,
|
||||||
"max_write_buffer_count" : 2147483647,
|
"max_write_buffer_count": 2147483647,
|
||||||
"max_write_buffer_size" : "512mb",
|
"max_write_buffer_size": "512mb",
|
||||||
"max_retry_delay" : "500ms",
|
"max_retry_delay": "500ms",
|
||||||
"read_poll_timeout" : "1m"
|
"read_poll_timeout": "1m"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -187,12 +187,12 @@ If the follower index is `paused`, the API returns the following results:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"follower_indices" : [
|
"follower_indices": [
|
||||||
{
|
{
|
||||||
"follower_index" : "follower_index",
|
"follower_index": "follower_index",
|
||||||
"remote_cluster" : "remote_cluster",
|
"remote_cluster": "remote_cluster",
|
||||||
"leader_index" : "leader_index",
|
"leader_index": "leader_index",
|
||||||
"status" : "paused"
|
"status": "paused"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,17 +185,17 @@ This is a short example of a simple reroute API call:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_cluster/reroute
|
POST /_cluster/reroute
|
||||||
{
|
{
|
||||||
"commands" : [
|
"commands": [
|
||||||
{
|
{
|
||||||
"move" : {
|
"move": {
|
||||||
"index" : "test", "shard" : 0,
|
"index": "test", "shard": 0,
|
||||||
"from_node" : "node1", "to_node" : "node2"
|
"from_node": "node1", "to_node": "node2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allocate_replica" : {
|
"allocate_replica": {
|
||||||
"index" : "test", "shard" : 1,
|
"index": "test", "shard": 1,
|
||||||
"node" : "node3"
|
"node": "node3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -35,21 +35,22 @@ You can see the assigned sequence number and primary term in the
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"failed" : 0,
|
"failed": 0,
|
||||||
"successful" : 1
|
"successful": 1
|
||||||
},
|
},
|
||||||
"_index" : "products",
|
"_index": "products",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1567",
|
"_id": "1567",
|
||||||
"_version" : 1,
|
"_version": 1,
|
||||||
"_seq_no" : 362,
|
"_seq_no": 362,
|
||||||
"_primary_term" : 2,
|
"_primary_term": 2,
|
||||||
"result" : "created"
|
"result": "created"
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 2/"_primary_term" : $body._primary_term/]
|
// TESTRESPONSE[s/"_seq_no": 362/"_seq_no": $body._seq_no/]
|
||||||
|
// TESTRESPONSE[s/"_primary_term": 2/"_primary_term": $body._primary_term/]
|
||||||
|
|
||||||
|
|
||||||
Elasticsearch keeps tracks of the sequence number and primary term of the last
|
Elasticsearch keeps tracks of the sequence number and primary term of the last
|
||||||
|
@ -68,20 +69,21 @@ returns:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_index" : "products",
|
"_index": "products",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1567",
|
"_id": "1567",
|
||||||
"_version" : 1,
|
"_version": 1,
|
||||||
"_seq_no" : 362,
|
"_seq_no": 362,
|
||||||
"_primary_term" : 2,
|
"_primary_term": 2,
|
||||||
"found": true,
|
"found": true,
|
||||||
"_source" : {
|
"_source": {
|
||||||
"product" : "r2d2",
|
"product": "r2d2",
|
||||||
"details" : "A resourceful astromech droid"
|
"details": "A resourceful astromech droid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 2/"_primary_term" : $body._primary_term/]
|
// TESTRESPONSE[s/"_seq_no": 362/"_seq_no": $body._seq_no/]
|
||||||
|
// TESTRESPONSE[s/"_primary_term": 2/"_primary_term": $body._primary_term/]
|
||||||
|
|
||||||
|
|
||||||
Note: The <<search-search,Search API>> can return the `_seq_no` and `_primary_term`
|
Note: The <<search-search,Search API>> can return the `_seq_no` and `_primary_term`
|
||||||
|
@ -102,9 +104,9 @@ of another tag by another API:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT products/_doc/1567?if_seq_no=362&if_primary_term=2
|
PUT products/_doc/1567?if_seq_no=362&if_primary_term=2
|
||||||
{
|
{
|
||||||
"product" : "r2d2",
|
"product": "r2d2",
|
||||||
"details" : "A resourceful astromech droid",
|
"details": "A resourceful astromech droid",
|
||||||
"tags": ["droid"]
|
"tags": [ "droid" ]
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -179,20 +179,20 @@ The API returns the following result:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"failed" : 0,
|
"failed": 0,
|
||||||
"successful" : 2
|
"successful": 2
|
||||||
},
|
},
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1",
|
"_id": "1",
|
||||||
"_version" : 2,
|
"_version": 2,
|
||||||
"_primary_term": 1,
|
"_primary_term": 1,
|
||||||
"_seq_no": 5,
|
"_seq_no": 5,
|
||||||
"result": "deleted"
|
"result": "deleted"
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
|
// TESTRESPONSE[s/"successful": 2/"successful": 1/]
|
||||||
// TESTRESPONSE[s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
|
// TESTRESPONSE[s/"_primary_term": 1/"_primary_term": $body._primary_term/]
|
||||||
// TESTRESPONSE[s/"_seq_no" : 5/"_seq_no" : $body._seq_no/]
|
// TESTRESPONSE[s/"_seq_no": 5/"_seq_no": $body._seq_no/]
|
||||||
|
|
|
@ -234,22 +234,22 @@ The API returns the following result:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "0",
|
"_id": "0",
|
||||||
"_version" : 1,
|
"_version": 1,
|
||||||
"_seq_no" : 10,
|
"_seq_no": 10,
|
||||||
"_primary_term" : 1,
|
"_primary_term": 1,
|
||||||
"found": true,
|
"found": true,
|
||||||
"_source" : {
|
"_source": {
|
||||||
"user" : "kimchy",
|
"user": "kimchy",
|
||||||
"date" : "2009-11-15T14:12:12",
|
"date": "2009-11-15T14:12:12",
|
||||||
"likes": 0,
|
"likes": 0,
|
||||||
"message" : "trying out Elasticsearch"
|
"message": "trying out Elasticsearch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
|
// TESTRESPONSE[s/"_seq_no": \d+/"_seq_no": $body._seq_no/ s/"_primary_term": 1/"_primary_term": $body._primary_term/]
|
||||||
|
|
||||||
Check to see if a document with the `_id` 0 exists:
|
Check to see if a document with the `_id` 0 exists:
|
||||||
|
|
||||||
|
@ -327,8 +327,8 @@ Now we can add a document:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT twitter/_doc/1
|
PUT twitter/_doc/1
|
||||||
{
|
{
|
||||||
"counter" : 1,
|
"counter": 1,
|
||||||
"tags" : ["red"]
|
"tags": [ "red" ]
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -250,21 +250,21 @@ The API returns the following result:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"failed" : 0,
|
"failed": 0,
|
||||||
"successful" : 2
|
"successful": 2
|
||||||
},
|
},
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "W0tpsmIBdwcYyG50zbta",
|
"_id": "W0tpsmIBdwcYyG50zbta",
|
||||||
"_version" : 1,
|
"_version": 1,
|
||||||
"_seq_no" : 0,
|
"_seq_no": 0,
|
||||||
"_primary_term" : 1,
|
"_primary_term": 1,
|
||||||
"result": "created"
|
"result": "created"
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/W0tpsmIBdwcYyG50zbta/$body._id/ s/"successful" : 2/"successful" : 1/]
|
// TESTRESPONSE[s/W0tpsmIBdwcYyG50zbta/$body._id/ s/"successful": 2/"successful": 1/]
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
[[optimistic-concurrency-control-index]]
|
[[optimistic-concurrency-control-index]]
|
||||||
|
@ -366,10 +366,10 @@ replication succeeded/failed.
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"failed" : 0,
|
"failed": 0,
|
||||||
"successful" : 2
|
"successful": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -512,21 +512,21 @@ The API returns the following result:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"failed" : 0,
|
"failed": 0,
|
||||||
"successful" : 2
|
"successful": 2
|
||||||
},
|
},
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1",
|
"_id": "1",
|
||||||
"_version" : 1,
|
"_version": 1,
|
||||||
"_seq_no" : 0,
|
"_seq_no": 0,
|
||||||
"_primary_term" : 1,
|
"_primary_term": 1,
|
||||||
"result" : "created"
|
"result": "created"
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
|
// TESTRESPONSE[s/"successful": 2/"successful": 1/]
|
||||||
|
|
||||||
Use the `_create` resource to index a document into the `twitter` index if
|
Use the `_create` resource to index a document into the `twitter` index if
|
||||||
no document with that ID exists:
|
no document with that ID exists:
|
||||||
|
|
|
@ -10,14 +10,14 @@ Retrieves multiple JSON documents by ID.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_mget
|
GET /_mget
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_id" : "1"
|
"_id": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "twitter",
|
"_index": "twitter",
|
||||||
"_id" : "2"
|
"_id": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -130,14 +130,14 @@ If you specify an index in the request URI, only the document IDs are required i
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /twitter/_mget
|
GET /twitter/_mget
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1"
|
"_id": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "2"
|
"_id": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,12 @@ And type:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /test/_doc/_mget
|
GET /test/_doc/_mget
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_id" : "1"
|
"_id": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : "2"
|
"_id": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -189,26 +189,26 @@ from document 3 but filters out the `user.location` field.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_mget
|
GET /_mget
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1",
|
"_id": "1",
|
||||||
"_source" : false
|
"_source": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "2",
|
"_id": "2",
|
||||||
"_source" : ["field3", "field4"]
|
"_source": [ "field3", "field4" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "3",
|
"_id": "3",
|
||||||
"_source" : {
|
"_source": {
|
||||||
"include": ["user"],
|
"include": [ "user" ],
|
||||||
"exclude": ["user.location"]
|
"exclude": [ "user.location" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -230,18 +230,18 @@ For example, the following request retrieves `field1` and `field2` from document
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_mget
|
GET /_mget
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1",
|
"_id": "1",
|
||||||
"stored_fields" : ["field1", "field2"]
|
"stored_fields": [ "field1", "field2" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "2",
|
"_id": "2",
|
||||||
"stored_fields" : ["field3", "field4"]
|
"stored_fields": [ "field3", "field4" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -255,13 +255,13 @@ overridden to return `field3` and `field4` for document 2.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /test/_doc/_mget?stored_fields=field1,field2
|
GET /test/_doc/_mget?stored_fields=field1,field2
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_id" : "1"
|
"_id": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : "2",
|
"_id": "2",
|
||||||
"stored_fields" : ["field3", "field4"]
|
"stored_fields": [ "field3", "field4" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -278,17 +278,17 @@ and fetches `test/_doc/1` from the shard corresponding to routing key `key2`.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_mget?routing=key1
|
GET /_mget?routing=key1
|
||||||
{
|
{
|
||||||
"docs" : [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "1",
|
"_id": "1",
|
||||||
"routing" : "key2"
|
"routing": "key2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "test",
|
"_index": "test",
|
||||||
"_type" : "_doc",
|
"_type": "_doc",
|
||||||
"_id" : "2"
|
"_id": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ following simplified syntax:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /twitter/_mtermvectors
|
POST /twitter/_mtermvectors
|
||||||
{
|
{
|
||||||
"ids" : ["1", "2"],
|
"ids": [ "1", "2" ],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"fields": [
|
"fields": [
|
||||||
"message"
|
"message"
|
||||||
|
|
|
@ -430,14 +430,14 @@ GET /imdb/_termvectors
|
||||||
"doc": {
|
"doc": {
|
||||||
"plot": "When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil."
|
"plot": "When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil."
|
||||||
},
|
},
|
||||||
"term_statistics" : true,
|
"term_statistics": true,
|
||||||
"field_statistics" : true,
|
"field_statistics": true,
|
||||||
"positions": false,
|
"positions": false,
|
||||||
"offsets": false,
|
"offsets": false,
|
||||||
"filter" : {
|
"filter": {
|
||||||
"max_num_terms" : 3,
|
"max_num_terms": 3,
|
||||||
"min_term_freq" : 1,
|
"min_term_freq": 1,
|
||||||
"min_doc_freq" : 1
|
"min_doc_freq": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
|
@ -116,11 +116,11 @@ Similarly, you could use and update script to add a tag to the list of tags
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "ctx._source.tags.add(params.tag)",
|
"source": "ctx._source.tags.add(params.tag)",
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"params" : {
|
"params": {
|
||||||
"tag" : "blue"
|
"tag": "blue"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,11 +137,11 @@ script just removes one occurrence.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }",
|
"source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }",
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"params" : {
|
"params": {
|
||||||
"tag" : "blue"
|
"tag": "blue"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,11 +179,11 @@ the `tags` field contains `green`, otherwise it does nothing (`noop`):
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'none' }",
|
"source": "if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'none' }",
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"params" : {
|
"params": {
|
||||||
"tag" : "green"
|
"tag": "green"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,8 @@ existing document:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"doc" : {
|
"doc": {
|
||||||
"name" : "new_name"
|
"name": "new_name"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -220,8 +220,8 @@ anything and return `"result": "noop"`:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"doc" : {
|
"doc": {
|
||||||
"name" : "new_name"
|
"name": "new_name"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -254,8 +254,8 @@ You can disable this behavior by setting `"detect_noop": false`:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"doc" : {
|
"doc": {
|
||||||
"name" : "new_name"
|
"name": "new_name"
|
||||||
},
|
},
|
||||||
"detect_noop": false
|
"detect_noop": false
|
||||||
}
|
}
|
||||||
|
@ -274,15 +274,15 @@ are inserted as a new document. If the document exists, the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "ctx._source.counter += params.count",
|
"source": "ctx._source.counter += params.count",
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"params" : {
|
"params": {
|
||||||
"count" : 4
|
"count": 4
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"upsert" : {
|
"upsert": {
|
||||||
"counter" : 1
|
"counter": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -299,18 +299,18 @@ To run the script whether or not the document exists, set `scripted_upsert` to
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST sessions/_update/dh3sgudg8gsrgl
|
POST sessions/_update/dh3sgudg8gsrgl
|
||||||
{
|
{
|
||||||
"scripted_upsert":true,
|
"scripted_upsert": true,
|
||||||
"script" : {
|
"script": {
|
||||||
"id": "my_web_session_summariser",
|
"id": "my_web_session_summariser",
|
||||||
"params" : {
|
"params": {
|
||||||
"pageViewEvent" : {
|
"pageViewEvent": {
|
||||||
"url":"foo.com/bar",
|
"url": "foo.com/bar",
|
||||||
"response":404,
|
"response": 404,
|
||||||
"time":"2014-01-01 12:32"
|
"time": "2014-01-01 12:32"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"upsert" : {}
|
"upsert": {}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[s/"id": "my_web_session_summariser"/"source": "ctx._source.page_view_event = params.pageViewEvent"/]
|
// TEST[s/"id": "my_web_session_summariser"/"source": "ctx._source.page_view_event = params.pageViewEvent"/]
|
||||||
|
@ -328,10 +328,10 @@ value:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST test/_update/1
|
POST test/_update/1
|
||||||
{
|
{
|
||||||
"doc" : {
|
"doc": {
|
||||||
"name" : "new_name"
|
"name": "new_name"
|
||||||
},
|
},
|
||||||
"doc_as_upsert" : true
|
"doc_as_upsert": true
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -312,10 +312,10 @@ POST clicklogs/_graph/explore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"controls": {
|
"controls": {
|
||||||
"use_significance": false,<1>
|
"use_significance": false, <1>
|
||||||
"sample_size": 2000,<2>
|
"sample_size": 2000, <2>
|
||||||
"timeout": 2000,<3>
|
"timeout": 2000, <3>
|
||||||
"sample_diversity": {<4>
|
"sample_diversity": { <4>
|
||||||
"field": "category.raw",
|
"field": "category.raw",
|
||||||
"max_docs_per_value": 500
|
"max_docs_per_value": 500
|
||||||
}
|
}
|
||||||
|
@ -323,13 +323,13 @@ POST clicklogs/_graph/explore
|
||||||
"vertices": [
|
"vertices": [
|
||||||
{
|
{
|
||||||
"field": "product",
|
"field": "product",
|
||||||
"size": 5,<5>
|
"size": 5, <5>
|
||||||
"min_doc_count": 10,<6>
|
"min_doc_count": 10, <6>
|
||||||
"shard_min_doc_count": 3<7>
|
"shard_min_doc_count": 3 <7>
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"connections": {
|
"connections": {
|
||||||
"query": {<8>
|
"query": { <8>
|
||||||
"bool": {
|
"bool": {
|
||||||
"filter": [
|
"filter": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,13 +123,13 @@ PUT index
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET index/_search
|
GET index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"script_score" : {
|
"script_score": {
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "body": "elasticsearch" }
|
"match": { "body": "elasticsearch" }
|
||||||
},
|
},
|
||||||
"script" : {
|
"script": {
|
||||||
"source" : "_score * saturation(doc['pagerank'].value, 10)" <1>
|
"source": "_score * saturation(doc['pagerank'].value, 10)" <1>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,8 +168,8 @@ PUT index
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _search
|
GET _search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must": {
|
"must": {
|
||||||
"match": { "body": "elasticsearch" }
|
"match": { "body": "elasticsearch" }
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,10 +16,10 @@ For instance the following example shows how to define a sort on a single field:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT twitter
|
PUT twitter
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"sort.field" : "date", <1>
|
"sort.field": "date", <1>
|
||||||
"sort.order" : "desc" <2>
|
"sort.order": "desc" <2>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
@ -41,10 +41,10 @@ It is also possible to sort the index by more than one field:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT twitter
|
PUT twitter
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"sort.field" : ["username", "date"], <1>
|
"sort.field": [ "username", "date" ], <1>
|
||||||
"sort.order" : ["asc", "desc"] <2>
|
"sort.order": [ "asc", "desc" ] <2>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
@ -114,10 +114,10 @@ For example, let's say we have an index that contains events sorted by a timesta
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT events
|
PUT events
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"sort.field" : "timestamp",
|
"sort.field": "timestamp",
|
||||||
"sort.order" : "desc" <1>
|
"sort.order": "desc" <1>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
|
|
@ -119,16 +119,16 @@ to add an index alias during index creation.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /logs_20302801
|
PUT /logs_20302801
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"year" : {"type" : "integer"}
|
"year": { "type": "integer" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aliases" : {
|
"aliases": {
|
||||||
"current_day" : {},
|
"current_day": {},
|
||||||
"2030" : {
|
"2030": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"term" : {"year" : 2030 }
|
"term": { "year": 2030 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,12 +320,12 @@ Now we can create an alias that uses a filter on field `user`:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_aliases
|
POST /_aliases
|
||||||
{
|
{
|
||||||
"actions" : [
|
"actions": [
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test1",
|
"index": "test1",
|
||||||
"alias" : "alias2",
|
"alias": "alias2",
|
||||||
"filter" : { "term" : { "user" : "kimchy" } }
|
"filter": { "term": { "user": "kimchy" } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -348,12 +348,12 @@ automatically modified to use value `1` for routing:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_aliases
|
POST /_aliases
|
||||||
{
|
{
|
||||||
"actions" : [
|
"actions": [
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test",
|
"index": "test",
|
||||||
"alias" : "alias1",
|
"alias": "alias1",
|
||||||
"routing" : "1"
|
"routing": "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -368,13 +368,13 @@ and indexing operations:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_aliases
|
POST /_aliases
|
||||||
{
|
{
|
||||||
"actions" : [
|
"actions": [
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test",
|
"index": "test",
|
||||||
"alias" : "alias2",
|
"alias": "alias2",
|
||||||
"search_routing" : "1,2",
|
"search_routing": "1,2",
|
||||||
"index_routing" : "2"
|
"index_routing": "2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -415,18 +415,18 @@ Rollover (see <<indices-rollover-index, Rollover With Write Index>>).
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_aliases
|
POST /_aliases
|
||||||
{
|
{
|
||||||
"actions" : [
|
"actions": [
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test",
|
"index": "test",
|
||||||
"alias" : "alias1",
|
"alias": "alias1",
|
||||||
"is_write_index" : true
|
"is_write_index": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test2",
|
"index": "test2",
|
||||||
"alias" : "alias1"
|
"alias": "alias1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -462,18 +462,18 @@ do an atomic swap. The swap is not dependent on the ordering of the actions.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /_aliases
|
POST /_aliases
|
||||||
{
|
{
|
||||||
"actions" : [
|
"actions": [
|
||||||
{
|
{
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test",
|
"index": "test",
|
||||||
"alias" : "alias1",
|
"alias": "alias1",
|
||||||
"is_write_index" : false
|
"is_write_index": false
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"add" : {
|
"add": {
|
||||||
"index" : "test2",
|
"index": "test2",
|
||||||
"alias" : "alias1",
|
"alias": "alias1",
|
||||||
"is_write_index" : true
|
"is_write_index": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -103,19 +103,19 @@ NOTE: Using the following analyzer as an index analyzer results in an error.
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"analysis" : {
|
"analysis": {
|
||||||
"analyzer" : {
|
"analyzer": {
|
||||||
"my_synonyms" : {
|
"my_synonyms": {
|
||||||
"tokenizer" : "whitespace",
|
"tokenizer": "whitespace",
|
||||||
"filter" : ["synonym"]
|
"filter": [ "synonym" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"synonym" : {
|
"synonym": {
|
||||||
"type" : "synonym_graph",
|
"type": "synonym_graph",
|
||||||
"synonyms_path" : "analysis/synonym.txt", <1>
|
"synonyms_path": "analysis/synonym.txt", <1>
|
||||||
"updateable" : true <2>
|
"updateable": true <2>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ PUT /my_index
|
||||||
"properties": {
|
"properties": {
|
||||||
"text": {
|
"text": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"analyzer" : "standard",
|
"analyzer": "standard",
|
||||||
"search_analyzer": "my_synonyms" <3>
|
"search_analyzer": "my_synonyms" <3>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,18 +153,18 @@ The API returns the following response.
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 2,
|
"total": 2,
|
||||||
"successful" : 2,
|
"successful": 2,
|
||||||
"failed" : 0
|
"failed": 0
|
||||||
},
|
},
|
||||||
"reload_details" : [
|
"reload_details": [
|
||||||
{
|
{
|
||||||
"index" : "my_index",
|
"index": "my_index",
|
||||||
"reloaded_analyzers" : [
|
"reloaded_analyzers": [
|
||||||
"my_synonyms"
|
"my_synonyms"
|
||||||
],
|
],
|
||||||
"reloaded_node_ids" : [
|
"reloaded_node_ids": [
|
||||||
"mfdqTXn_T7SGr2Ho2KT8uw"
|
"mfdqTXn_T7SGr2Ho2KT8uw"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,6 @@ The API returns the following response.
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
// TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/]
|
// TESTRESPONSE[s/"total": 2/"total": $body._shards.total/]
|
||||||
// TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/]
|
// TESTRESPONSE[s/"successful": 2/"successful": $body._shards.successful/]
|
||||||
// TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
|
// TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
|
||||||
|
|
|
@ -73,11 +73,11 @@ The API returns following response:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"acknowledged" : true,
|
"acknowledged": true,
|
||||||
"shards_acknowledged" : true,
|
"shards_acknowledged": true,
|
||||||
"indices" : {
|
"indices": {
|
||||||
"my_index" : {
|
"my_index": {
|
||||||
"closed" : true
|
"closed": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,10 +83,10 @@ associated with it, defined in the body:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /twitter
|
PUT /twitter
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"index" : {
|
"index": {
|
||||||
"number_of_shards" : 3, <1>
|
"number_of_shards": 3, <1>
|
||||||
"number_of_replicas" : 2 <2>
|
"number_of_replicas": 2 <2>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,9 @@ or more simplified
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /twitter
|
PUT /twitter
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"number_of_shards" : 3,
|
"number_of_shards": 3,
|
||||||
"number_of_replicas" : 2
|
"number_of_replicas": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -125,12 +125,12 @@ The create index API allows for providing a mapping definition:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /test
|
PUT /test
|
||||||
{
|
{
|
||||||
"settings" : {
|
"settings": {
|
||||||
"number_of_shards" : 1
|
"number_of_shards": 1
|
||||||
},
|
},
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"field1" : { "type" : "text" }
|
"field1": { "type": "text" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,13 +149,13 @@ The create index API allows also to provide a set of <<indices-aliases,aliases>>
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /test
|
PUT /test
|
||||||
{
|
{
|
||||||
"aliases" : {
|
"aliases": {
|
||||||
"alias_1" : {},
|
"alias_1": {},
|
||||||
"alias_2" : {
|
"alias_2": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"term" : {"user" : "kimchy" }
|
"term": { "user": "kimchy" }
|
||||||
},
|
},
|
||||||
"routing" : "kimchy"
|
"routing": "kimchy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ PUT /publications
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "text" },
|
"id": { "type": "text" },
|
||||||
"title": { "type": "text"},
|
"title": { "type": "text" },
|
||||||
"abstract": { "type": "text"},
|
"abstract": { "type": "text" },
|
||||||
"author": {
|
"author": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "text" },
|
"id": { "type": "text" },
|
||||||
|
|
|
@ -14,9 +14,9 @@ Deletes an existing <<enrich-policy,enrich policy>> and its
|
||||||
----
|
----
|
||||||
PUT /users
|
PUT /users
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"email" : { "type" : "keyword" }
|
"email": { "type": "keyword" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ PUT /_enrich/policy/my-policy
|
||||||
"match": {
|
"match": {
|
||||||
"indices": "users",
|
"indices": "users",
|
||||||
"match_field": "email",
|
"match_field": "email",
|
||||||
"enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
|
"enrich_fields": [ "first_name", "last_name", "city", "zip", "state" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
|
@ -105,15 +105,15 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"name": "my-policy",
|
"name": "my-policy",
|
||||||
"task": {
|
"task": {
|
||||||
"id" : 124,
|
"id": 124,
|
||||||
"type" : "direct",
|
"type": "direct",
|
||||||
"action" : "cluster:admin/xpack/enrich/execute",
|
"action": "cluster:admin/xpack/enrich/execute",
|
||||||
"start_time_in_millis" : 1458585884904,
|
"start_time_in_millis": 1458585884904,
|
||||||
"running_time_in_nanos" : 47402,
|
"running_time_in_nanos": 47402,
|
||||||
"cancellable" : false,
|
"cancellable": false,
|
||||||
"parent_task_id" : "oTUltX4IQMOUUVeiohTt8A:123",
|
"parent_task_id": "oTUltX4IQMOUUVeiohTt8A:123",
|
||||||
"headers" : {
|
"headers": {
|
||||||
"X-Opaque-Id" : "123456"
|
"X-Opaque-Id": "123456"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,10 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"match": {
|
"match": {
|
||||||
"name" : "my-policy",
|
"name": "my-policy",
|
||||||
"indices" : ["users"],
|
"indices": [ "users" ],
|
||||||
"match_field" : "email",
|
"match_field": "email",
|
||||||
"enrich_fields" : [
|
"enrich_fields": [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"city",
|
"city",
|
||||||
|
@ -136,10 +136,10 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"match": {
|
"match": {
|
||||||
"name" : "my-policy",
|
"name": "my-policy",
|
||||||
"indices" : ["users"],
|
"indices": [ "users" ],
|
||||||
"match_field" : "email",
|
"match_field": "email",
|
||||||
"enrich_fields" : [
|
"enrich_fields": [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"city",
|
"city",
|
||||||
|
@ -152,10 +152,10 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"match": {
|
"match": {
|
||||||
"name" : "other-policy",
|
"name": "other-policy",
|
||||||
"indices" : ["users"],
|
"indices": [ "users" ],
|
||||||
"match_field" : "email",
|
"match_field": "email",
|
||||||
"enrich_fields" : [
|
"enrich_fields": [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"city",
|
"city",
|
||||||
|
@ -189,10 +189,10 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"match": {
|
"match": {
|
||||||
"name" : "my-policy",
|
"name": "my-policy",
|
||||||
"indices" : ["users"],
|
"indices": [ "users" ],
|
||||||
"match_field" : "email",
|
"match_field": "email",
|
||||||
"enrich_fields" : [
|
"enrich_fields": [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"city",
|
"city",
|
||||||
|
@ -205,10 +205,10 @@ The API returns the following response:
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"match": {
|
"match": {
|
||||||
"name" : "other-policy",
|
"name": "other-policy",
|
||||||
"indices" : ["users"],
|
"indices": [ "users" ],
|
||||||
"match_field" : "email",
|
"match_field": "email",
|
||||||
"enrich_fields" : [
|
"enrich_fields": [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"city",
|
"city",
|
||||||
|
|
|
@ -13,9 +13,9 @@ Creates an enrich policy.
|
||||||
----
|
----
|
||||||
PUT /users
|
PUT /users
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"email" : { "type" : "keyword" }
|
"email": { "type": "keyword" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,11 +244,10 @@ following:
|
||||||
----
|
----
|
||||||
{
|
{
|
||||||
"<enrich_policy_type>": {
|
"<enrich_policy_type>": {
|
||||||
"indices": ["..."],
|
"indices": [ "..." ],
|
||||||
"match_field": "...",
|
"match_field": "...",
|
||||||
"enrich_fields": ["..."],
|
"enrich_fields": [ "..." ],
|
||||||
"query": {...}
|
"query": {... }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
@ -342,7 +341,7 @@ PUT /postal_codes/_doc/1?refresh=wait_for
|
||||||
{
|
{
|
||||||
"location": {
|
"location": {
|
||||||
"type": "envelope",
|
"type": "envelope",
|
||||||
"coordinates": [[13.0, 53.0], [14.0, 52.0]]
|
"coordinates": [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]
|
||||||
},
|
},
|
||||||
"postal_code": "96598"
|
"postal_code": "96598"
|
||||||
}
|
}
|
||||||
|
@ -365,7 +364,7 @@ PUT /_enrich/policy/postal_policy
|
||||||
"geo_match": {
|
"geo_match": {
|
||||||
"indices": "postal_codes",
|
"indices": "postal_codes",
|
||||||
"match_field": "location",
|
"match_field": "location",
|
||||||
"enrich_fields": ["location","postal_code"]
|
"enrich_fields": [ "location", "postal_code" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
|
@ -231,16 +231,16 @@ PUT my_ip_locations/_doc/1?refresh=true&pipeline=geoip
|
||||||
GET /my_ip_locations/_search
|
GET /my_ip_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_distance" : {
|
"geo_distance": {
|
||||||
"distance" : "1m",
|
"distance": "1m",
|
||||||
"geoip.location" : {
|
"geoip.location": {
|
||||||
"lon" : -97.822,
|
"lon": -97.822,
|
||||||
"lat" : 37.751
|
"lat": 37.751
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ was provided in the original index request:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _ingest/pipeline/my_index
|
PUT _ingest/pipeline/my_index
|
||||||
{
|
{
|
||||||
"description": "use index:my_index and type:_doc",
|
"description": "use index:my_index",
|
||||||
"processors": [
|
"processors": [
|
||||||
{
|
{
|
||||||
"script": {
|
"script": {
|
||||||
|
|
|
@ -180,7 +180,7 @@ Will return:
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 4,
|
"value": 4,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,9 +40,9 @@ Then you can index a query:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT my_index/_doc/match_value
|
PUT my_index/_doc/match_value
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"field" : "value"
|
"field": "value"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,17 +41,17 @@ The following example validates job configuration information:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _ml/anomaly_detectors/_validate
|
POST _ml/anomaly_detectors/_validate
|
||||||
{
|
{
|
||||||
"description" : "Unusual response times by airlines",
|
"description": "Unusual response times by airlines",
|
||||||
"analysis_config" : {
|
"analysis_config": {
|
||||||
"bucket_span": "300S",
|
"bucket_span": "300S",
|
||||||
"detectors" :[
|
"detectors": [
|
||||||
{
|
{
|
||||||
"function": "metric",
|
"function": "metric",
|
||||||
"field_name": "responsetime",
|
"field_name": "responsetime",
|
||||||
"by_field_name": "airline"}],
|
"by_field_name": "airline" } ],
|
||||||
"influencers": [ "airline" ]
|
"influencers": [ "airline" ]
|
||||||
},
|
},
|
||||||
"data_description" : {
|
"data_description": {
|
||||||
"time_field": "time",
|
"time_field": "time",
|
||||||
"time_format": "yyyy-MM-dd'T'HH:mm:ssX"
|
"time_format": "yyyy-MM-dd'T'HH:mm:ssX"
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ The API returns the following results:
|
||||||
},
|
},
|
||||||
"model_memory_limit": "1gb",
|
"model_memory_limit": "1gb",
|
||||||
"create_time": 1562265491319,
|
"create_time": 1562265491319,
|
||||||
"version" : "8.0.0"
|
"version": "8.0.0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,18 +19,18 @@ excluding them from the search results.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"boosting" : {
|
"boosting": {
|
||||||
"positive" : {
|
"positive": {
|
||||||
"term" : {
|
"term": {
|
||||||
"text" : "apple"
|
"text": "apple"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"negative" : {
|
"negative": {
|
||||||
"term" : {
|
"term": {
|
||||||
"text" : "pie tart fruit crumble tree"
|
"text": "pie tart fruit crumble tree"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"negative_boost" : 0.5
|
"negative_boost": 0.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ parameter value.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"constant_score" : {
|
"constant_score": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"term" : { "user" : "kimchy"}
|
"term": { "user": "kimchy" }
|
||||||
},
|
},
|
||||||
"boost" : 1.2
|
"boost": 1.2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,12 @@ You can use the `dis_max` to search for a term in fields mapped with different
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"dis_max" : {
|
"dis_max": {
|
||||||
"queries" : [
|
"queries": [
|
||||||
{ "term" : { "title" : "Quick pets" }},
|
{ "term": { "title": "Quick pets" } },
|
||||||
{ "term" : { "body" : "Quick pets" }}
|
{ "term": { "body": "Quick pets" } }
|
||||||
],
|
],
|
||||||
"tie_breaker" : 0.7
|
"tie_breaker": 0.7
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ GET /_search
|
||||||
"query": { "match_all": {} },
|
"query": { "match_all": {} },
|
||||||
"boost": "5",
|
"boost": "5",
|
||||||
"random_score": {}, <1>
|
"random_score": {}, <1>
|
||||||
"boost_mode":"multiply"
|
"boost_mode": "multiply"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ GET /_search
|
||||||
"max_boost": 42,
|
"max_boost": 42,
|
||||||
"score_mode": "max",
|
"score_mode": "max",
|
||||||
"boost_mode": "multiply",
|
"boost_mode": "multiply",
|
||||||
"min_score" : 42
|
"min_score": 42
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,8 @@ GET /_search
|
||||||
"query": {
|
"query": {
|
||||||
"match": { "message": "elasticsearch" }
|
"match": { "message": "elasticsearch" }
|
||||||
},
|
},
|
||||||
"script_score" : {
|
"script_score": {
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "Math.log(2 + doc['likes'].value)"
|
"source": "Math.log(2 + doc['likes'].value)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,8 @@ GET /_search
|
||||||
"query": {
|
"query": {
|
||||||
"match": { "message": "elasticsearch" }
|
"match": { "message": "elasticsearch" }
|
||||||
},
|
},
|
||||||
"script_score" : {
|
"script_score": {
|
||||||
"script" : {
|
"script": {
|
||||||
"params": {
|
"params": {
|
||||||
"a": 5,
|
"a": 5,
|
||||||
"b": 1.2
|
"b": 1.2
|
||||||
|
@ -387,7 +387,7 @@ GET /_search
|
||||||
"origin": "2013-09-17", <1>
|
"origin": "2013-09-17", <1>
|
||||||
"scale": "10d",
|
"scale": "10d",
|
||||||
"offset": "5d", <2>
|
"offset": "5d", <2>
|
||||||
"decay" : 0.5 <2>
|
"decay": 0.5 <2>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@ PUT /my_locations
|
||||||
|
|
||||||
PUT /my_locations/_doc/1
|
PUT /my_locations/_doc/1
|
||||||
{
|
{
|
||||||
"pin" : {
|
"pin": {
|
||||||
"location" : {
|
"location": {
|
||||||
"lat" : 40.12,
|
"lat": 40.12,
|
||||||
"lon" : -71.34
|
"lon": -71.34
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,20 +44,20 @@ Then the following simple query can be executed with a
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : {
|
"top_left": {
|
||||||
"lat" : 40.73,
|
"lat": 40.73,
|
||||||
"lon" : -74.1
|
"lon": -74.1
|
||||||
},
|
},
|
||||||
"bottom_right" : {
|
"bottom_right": {
|
||||||
"lat" : 40.01,
|
"lat": 40.01,
|
||||||
"lon" : -71.12
|
"lon": -71.12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,20 +99,20 @@ representations of the geo point, the filter can accept it as well:
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : {
|
"top_left": {
|
||||||
"lat" : 40.73,
|
"lat": 40.73,
|
||||||
"lon" : -74.1
|
"lon": -74.1
|
||||||
},
|
},
|
||||||
"bottom_right" : {
|
"bottom_right": {
|
||||||
"lat" : 40.01,
|
"lat": 40.01,
|
||||||
"lon" : -71.12
|
"lon": -71.12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,15 +133,15 @@ conform with http://geojson.org/[GeoJSON].
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : [-74.1, 40.73],
|
"top_left": [ -74.1, 40.73 ],
|
||||||
"bottom_right" : [-71.12, 40.01]
|
"bottom_right": [ -71.12, 40.01 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,20 +160,20 @@ Format in `lat,lon`.
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : "40.73, -74.1",
|
"top_left": "40.73, -74.1",
|
||||||
"bottom_right" : "40.01, -71.12"
|
"bottom_right": "40.01, -71.12"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
@ -185,14 +185,14 @@ GET my_locations/_search
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"wkt" : "BBOX (-74.1, -71.12, 40.73, 40.01)"
|
"wkt": "BBOX (-74.1, -71.12, 40.73, 40.01)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,15 +209,15 @@ GET my_locations/_search
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : "dr5r9ydj2y73",
|
"top_left": "dr5r9ydj2y73",
|
||||||
"bottom_right" : "drj7teegpus6"
|
"bottom_right": "drj7teegpus6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,10 +243,10 @@ geohash the geohash can be specified in both `top_left` and
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : "dr",
|
"top_left": "dr",
|
||||||
"bottom_right" : "dr"
|
"bottom_right": "dr"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,17 +272,17 @@ values separately.
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top" : 40.73,
|
"top": 40.73,
|
||||||
"left" : -74.1,
|
"left": -74.1,
|
||||||
"bottom" : 40.01,
|
"bottom": 40.01,
|
||||||
"right" : -71.12
|
"right": -71.12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,23 +321,23 @@ are not supported. Here is an example:
|
||||||
GET my_locations/_search
|
GET my_locations/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_bounding_box" : {
|
"geo_bounding_box": {
|
||||||
"pin.location" : {
|
"pin.location": {
|
||||||
"top_left" : {
|
"top_left": {
|
||||||
"lat" : 40.73,
|
"lat": 40.73,
|
||||||
"lon" : -74.1
|
"lon": -74.1
|
||||||
},
|
},
|
||||||
"bottom_right" : {
|
"bottom_right": {
|
||||||
"lat" : 40.10,
|
"lat": 40.10,
|
||||||
"lon" : -71.12
|
"lon": -71.12
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type" : "indexed"
|
"type": "indexed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ PUT /my_locations
|
||||||
|
|
||||||
PUT /my_locations/_doc/1
|
PUT /my_locations/_doc/1
|
||||||
{
|
{
|
||||||
"pin" : {
|
"pin": {
|
||||||
"location" : {
|
"location": {
|
||||||
"lat" : 40.12,
|
"lat": 40.12,
|
||||||
"lon" : -71.34
|
"lon": -71.34
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,16 +46,16 @@ filter:
|
||||||
GET /my_locations/_search
|
GET /my_locations/_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,16 +78,16 @@ representations of the geo point, the filter can accept it as well:
|
||||||
GET /my_locations/_search
|
GET /my_locations/_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,14 +107,14 @@ conform with http://geojson.org/[GeoJSON].
|
||||||
GET /my_locations/_search
|
GET /my_locations/_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 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,14 +133,14 @@ Format in `lat,lon`.
|
||||||
GET /my_locations/_search
|
GET /my_locations/_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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,14 +156,14 @@ GET /my_locations/_search
|
||||||
GET /my_locations/_search
|
GET /my_locations/_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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,17 @@ points. Here is an example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_polygon" : {
|
"geo_polygon": {
|
||||||
"person.location" : {
|
"person.location": {
|
||||||
"points" : [
|
"points": [
|
||||||
{"lat" : 40, "lon" : -70},
|
{ "lat": 40, "lon": -70 },
|
||||||
{"lat" : 30, "lon" : -80},
|
{ "lat": 30, "lon": -80 },
|
||||||
{"lat" : 20, "lon" : -90}
|
{ "lat": 20, "lon": -90 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,17 +61,17 @@ conform with http://geojson.org/[GeoJSON].
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_polygon" : {
|
"geo_polygon": {
|
||||||
"person.location" : {
|
"person.location": {
|
||||||
"points" : [
|
"points": [
|
||||||
[-70, 40],
|
[ -70, 40 ],
|
||||||
[-80, 30],
|
[ -80, 30 ],
|
||||||
[-90, 20]
|
[ -90, 20 ]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,14 @@ Format in `lat,lon`.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_polygon" : {
|
"geo_polygon": {
|
||||||
"person.location" : {
|
"person.location": {
|
||||||
"points" : [
|
"points": [
|
||||||
"40, -70",
|
"40, -70",
|
||||||
"30, -80",
|
"30, -80",
|
||||||
"20, -90"
|
"20, -90"
|
||||||
|
@ -119,14 +119,14 @@ GET /_search
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"geo_polygon" : {
|
"geo_polygon": {
|
||||||
"person.location" : {
|
"person.location": {
|
||||||
"points" : [
|
"points": [
|
||||||
"drn5x1g8cu2y",
|
"drn5x1g8cu2y",
|
||||||
"30, -80",
|
"30, -80",
|
||||||
"20, -90"
|
"20, -90"
|
||||||
|
|
|
@ -45,7 +45,7 @@ POST /example/_doc?refresh
|
||||||
"name": "Wind & Wetter, Berlin, Germany",
|
"name": "Wind & Wetter, Berlin, Germany",
|
||||||
"location": {
|
"location": {
|
||||||
"type": "point",
|
"type": "point",
|
||||||
"coordinates": [13.400544, 52.530286]
|
"coordinates": [ 13.400544, 52.530286 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -59,7 +59,7 @@ extension:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /example/_search
|
GET /example/_search
|
||||||
{
|
{
|
||||||
"query":{
|
"query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"must": {
|
"must": {
|
||||||
"match_all": {}
|
"match_all": {}
|
||||||
|
@ -69,7 +69,7 @@ GET /example/_search
|
||||||
"location": {
|
"location": {
|
||||||
"shape": {
|
"shape": {
|
||||||
"type": "envelope",
|
"type": "envelope",
|
||||||
"coordinates" : [[13.0, 53.0], [14.0, 52.0]]
|
"coordinates": [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]
|
||||||
},
|
},
|
||||||
"relation": "within"
|
"relation": "within"
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ returned.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /example_points/_search
|
GET /example_points/_search
|
||||||
{
|
{
|
||||||
"query":{
|
"query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"must": {
|
"must": {
|
||||||
"match_all": {}
|
"match_all": {}
|
||||||
|
@ -122,7 +122,7 @@ GET /example_points/_search
|
||||||
"location": {
|
"location": {
|
||||||
"shape": {
|
"shape": {
|
||||||
"type": "envelope",
|
"type": "envelope",
|
||||||
"coordinates" : [[13.0, 53.0], [14.0, 52.0]]
|
"coordinates": [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]
|
||||||
},
|
},
|
||||||
"relation": "intersects"
|
"relation": "intersects"
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ field mapping. For example:
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"my-join-field" : {
|
"my-join-field": {
|
||||||
"type" : "join",
|
"type": "join",
|
||||||
"relations": {
|
"relations": {
|
||||||
"parent": "child"
|
"parent": "child"
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ PUT /my_index
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"has_child" : {
|
"has_child": {
|
||||||
"type" : "child",
|
"type": "child",
|
||||||
"query" : {
|
"query": {
|
||||||
"match_all" : {}
|
"match_all": {}
|
||||||
},
|
},
|
||||||
"max_children": 10,
|
"max_children": 10,
|
||||||
"min_children": 2,
|
"min_children": 2,
|
||||||
"score_mode" : "min"
|
"score_mode": "min"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,16 +142,16 @@ sorts returned documents by the `click_count` field of their child documents.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"has_child" : {
|
"has_child": {
|
||||||
"type" : "child",
|
"type": "child",
|
||||||
"query" : {
|
"query": {
|
||||||
"function_score" : {
|
"function_score": {
|
||||||
"script_score": {
|
"script_score": {
|
||||||
"script": "_score * doc['click_count'].value"
|
"script": "_score * doc['click_count'].value"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"score_mode" : "max"
|
"score_mode": "max"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,15 +28,15 @@ field mapping. For example:
|
||||||
PUT /my-index
|
PUT /my-index
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"my-join-field" : {
|
"my-join-field": {
|
||||||
"type" : "join",
|
"type": "join",
|
||||||
"relations": {
|
"relations": {
|
||||||
"parent": "child"
|
"parent": "child"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tag" : {
|
"tag": {
|
||||||
"type" : "keyword"
|
"type": "keyword"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ PUT /my-index
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"has_parent" : {
|
"has_parent": {
|
||||||
"parent_type" : "parent",
|
"parent_type": "parent",
|
||||||
"query" : {
|
"query": {
|
||||||
"term" : {
|
"term": {
|
||||||
"tag" : {
|
"tag": {
|
||||||
"value" : "Elasticsearch"
|
"value": "Elasticsearch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,11 +123,11 @@ sorts returned documents by the `view_count` field of their parent documents.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"has_parent" : {
|
"has_parent": {
|
||||||
"parent_type" : "parent",
|
"parent_type": "parent",
|
||||||
"score" : true,
|
"score": true,
|
||||||
"query" : {
|
"query": {
|
||||||
"function_score" : {
|
"function_score": {
|
||||||
"script_score": {
|
"script_score": {
|
||||||
"script": "_score * doc['view_count'].value"
|
"script": "_score * doc['view_count'].value"
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ configured with the `analyzer` parameter
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match_bool_prefix" : {
|
"match_bool_prefix": {
|
||||||
"message": {
|
"message": {
|
||||||
"query": "quick brown f",
|
"query": "quick brown f",
|
||||||
"analyzer": "keyword"
|
"analyzer": "keyword"
|
||||||
|
|
|
@ -23,9 +23,9 @@ brown ferrets` but not `the fox is quick and brown`.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match_phrase_prefix" : {
|
"match_phrase_prefix": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "quick brown f"
|
"query": "quick brown f"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ out of the analyzed text. For example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match_phrase" : {
|
"match_phrase": {
|
||||||
"message" : "this is a test"
|
"message": "this is a test"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ definition, or the default search analyzer, for example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match_phrase" : {
|
"match_phrase": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "this is a test",
|
"query": "this is a test",
|
||||||
"analyzer" : "my_analyzer"
|
"analyzer": "my_analyzer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ including options for fuzzy matching.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "this is a test"
|
"query": "this is a test"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,8 @@ parameters. For example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : "this is a test"
|
"message": "this is a test"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,10 @@ Here is an example with the `operator` parameter:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "this is a test",
|
"query": "this is a test",
|
||||||
"operator" : "and"
|
"operator": "and"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,9 +220,9 @@ which does not support fuzzy expansion.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "this is a testt",
|
"query": "this is a testt",
|
||||||
"fuzziness": "AUTO"
|
"fuzziness": "AUTO"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,10 +242,10 @@ change that the `zero_terms_query` option can be used, which accepts
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : {
|
"message": {
|
||||||
"query" : "to be or not to be",
|
"query": "to be or not to be",
|
||||||
"operator" : "and",
|
"operator": "and",
|
||||||
"zero_terms_query": "all"
|
"zero_terms_query": "all"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,21 +39,21 @@ 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",
|
||||||
"_id" : "1"
|
"_id": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "imdb",
|
"_index": "imdb",
|
||||||
"_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,12 +68,12 @@ 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",
|
||||||
"doc" : {
|
"doc": {
|
||||||
"name": {
|
"name": {
|
||||||
"first": "Ben",
|
"first": "Ben",
|
||||||
"last": "Grimm"
|
"last": "Grimm"
|
||||||
|
@ -82,12 +82,12 @@ GET /_search
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index" : "marvel",
|
"_index": "marvel",
|
||||||
"_id" : "2"
|
"_id": "2"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"min_term_freq" : 1,
|
"min_term_freq": 1,
|
||||||
"max_query_terms" : 12
|
"max_query_terms": 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,11 +132,11 @@ PUT /imdb
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"fields" : {
|
"fields": {
|
||||||
"raw": {
|
"raw": {
|
||||||
"type" : "text",
|
"type": "text",
|
||||||
"analyzer": "keyword",
|
"analyzer": "keyword",
|
||||||
"term_vector" : "yes"
|
"term_vector": "yes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ mapping. For example:
|
||||||
----
|
----
|
||||||
PUT /my_index
|
PUT /my_index
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"obj1" : {
|
"obj1": {
|
||||||
"type" : "nested"
|
"type": "nested"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,17 +42,17 @@ PUT /my_index
|
||||||
GET /my_index/_search
|
GET /my_index/_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"nested" : {
|
"nested": {
|
||||||
"path" : "obj1",
|
"path": "obj1",
|
||||||
"query" : {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : [
|
"must": [
|
||||||
{ "match" : {"obj1.name" : "blue"} },
|
{ "match": { "obj1.name": "blue" } },
|
||||||
{ "range" : {"obj1.count" : {"gt" : 5}} }
|
{ "range": { "obj1.count": { "gt": 5 } } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"score_mode" : "avg"
|
"score_mode": "avg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,22 +133,22 @@ with nested `make` and `model` fields.
|
||||||
----
|
----
|
||||||
PUT /drivers
|
PUT /drivers
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"driver" : {
|
"driver": {
|
||||||
"type" : "nested",
|
"type": "nested",
|
||||||
"properties" : {
|
"properties": {
|
||||||
"last_name" : {
|
"last_name": {
|
||||||
"type" : "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
"vehicle" : {
|
"vehicle": {
|
||||||
"type" : "nested",
|
"type": "nested",
|
||||||
"properties" : {
|
"properties": {
|
||||||
"make" : {
|
"make": {
|
||||||
"type" : "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
"model" : {
|
"model": {
|
||||||
"type" : "text"
|
"type": "text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,17 +206,17 @@ to match documents based on the `make` and `model` fields.
|
||||||
----
|
----
|
||||||
GET /drivers/_search
|
GET /drivers/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"nested" : {
|
"nested": {
|
||||||
"path" : "driver",
|
"path": "driver",
|
||||||
"query" : {
|
"query": {
|
||||||
"nested" : {
|
"nested": {
|
||||||
"path" : "driver.vehicle",
|
"path": "driver.vehicle",
|
||||||
"query" : {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : [
|
"must": [
|
||||||
{ "match" : { "driver.vehicle.make" : "Powell Motors" } },
|
{ "match": { "driver.vehicle.make": "Powell Motors" } },
|
||||||
{ "match" : { "driver.vehicle.model" : "Canyonero" } }
|
{ "match": { "driver.vehicle.model": "Canyonero" } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ the following example.
|
||||||
PUT /my-index
|
PUT /my-index
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"my-join-field" : {
|
"my-join-field": {
|
||||||
"type" : "join",
|
"type": "join",
|
||||||
"relations": {
|
"relations": {
|
||||||
"my-parent": "my-child"
|
"my-parent": "my-child"
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ Register a query in the percolator:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /my-index/_doc/1?refresh
|
PUT /my-index/_doc/1?refresh
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : "bonsai tree"
|
"message": "bonsai tree"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,11 +61,11 @@ Match a document to the registered percolator queries:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field" : "query",
|
"field": "query",
|
||||||
"document" : {
|
"document": {
|
||||||
"message" : "A new bonsai tree in the office"
|
"message": "A new bonsai tree in the office"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,13 +159,13 @@ the percolator query in a `bool` query's filter clause or in a `constant_score`
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"constant_score": {
|
"constant_score": {
|
||||||
"filter": {
|
"filter": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field" : "query",
|
"field": "query",
|
||||||
"document" : {
|
"document": {
|
||||||
"message" : "A new bonsai tree in the office"
|
"message": "A new bonsai tree in the office"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,21 +199,21 @@ correlate with the slot in the `documents` array specified in the `percolate` qu
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field" : "query",
|
"field": "query",
|
||||||
"documents" : [ <1>
|
"documents": [ <1>
|
||||||
{
|
{
|
||||||
"message" : "bonsai tree"
|
"message": "bonsai tree"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "new tree"
|
"message": "new tree"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "the office"
|
"message": "the office"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "office tree"
|
"message": "office tree"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -315,12 +315,12 @@ Percolating an existing document, using the index response as basis to build to
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field": "query",
|
"field": "query",
|
||||||
"index" : "my-index",
|
"index": "my-index",
|
||||||
"id" : "2",
|
"id": "2",
|
||||||
"version" : 1 <1>
|
"version": 1 <1>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,9 +351,9 @@ Save a query:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /my-index/_doc/3?refresh
|
PUT /my-index/_doc/3?refresh
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : "brown fox"
|
"message": "brown fox"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,9 +366,9 @@ Save another query:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT /my-index/_doc/4?refresh
|
PUT /my-index/_doc/4?refresh
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match" : {
|
"match": {
|
||||||
"message" : "lazy dog"
|
"message": "lazy dog"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,11 +381,11 @@ Execute a search request with the `percolate` query and highlighting enabled:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field": "query",
|
"field": "query",
|
||||||
"document" : {
|
"document": {
|
||||||
"message" : "The quick brown fox jumps over the lazy dog"
|
"message": "The quick brown fox jumps over the lazy dog"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -477,21 +477,21 @@ When percolating multiple documents at the same time like the request below then
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field": "query",
|
"field": "query",
|
||||||
"documents" : [
|
"documents": [
|
||||||
{
|
{
|
||||||
"message" : "bonsai tree"
|
"message": "bonsai tree"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "new tree"
|
"message": "new tree"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "the office"
|
"message": "the office"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message" : "office tree"
|
"message": "office tree"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -570,23 +570,23 @@ It is possible to specify multiple `percolate` queries in a single search reques
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /my-index/_search
|
GET /my-index/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"should" : [
|
"should": [
|
||||||
{
|
{
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field" : "query",
|
"field": "query",
|
||||||
"document" : {
|
"document": {
|
||||||
"message" : "bonsai tree"
|
"message": "bonsai tree"
|
||||||
},
|
},
|
||||||
"name": "query1" <1>
|
"name": "query1" <1>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"percolate" : {
|
"percolate": {
|
||||||
"field" : "query",
|
"field": "query",
|
||||||
"document" : {
|
"document": {
|
||||||
"message" : "tulip flower"
|
"message": "tulip flower"
|
||||||
},
|
},
|
||||||
"name": "query2" <1>
|
"name": "query2" <1>
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ the <<mapping-id-field,`_id`>> field.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"pinned" : {
|
"pinned": {
|
||||||
"ids" : ["1", "4", "100"],
|
"ids": [ "1", "4", "100" ],
|
||||||
"organic" : {
|
"organic": {
|
||||||
"match":{
|
"match": {
|
||||||
"description": "brown shoes"
|
"description": "iphone"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ whitespace as an operator, `new york city` is passed as-is to the analyzer.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"query_string" : {
|
"query_string": {
|
||||||
"query" : "(new york city) OR (big apple)",
|
"query": "(new york city) OR (big apple)",
|
||||||
"default_field" : "content"
|
"default_field": "content"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,9 +266,9 @@ For example, the following query
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"query_string" : {
|
"query_string": {
|
||||||
"fields" : ["content", "name"],
|
"fields": [ "content", "name" ],
|
||||||
"query" : "this AND that"
|
"query": "this AND that"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ between `10` and `20`.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"range" : {
|
"range": {
|
||||||
"age" : {
|
"age": {
|
||||||
"gte" : 10,
|
"gte": 10,
|
||||||
"lte" : 20,
|
"lte": 20,
|
||||||
"boost" : 2.0
|
"boost": 2.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,10 +158,10 @@ contains a date between today and yesterday.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"range" : {
|
"range": {
|
||||||
"timestamp" : {
|
"timestamp": {
|
||||||
"gte" : "now-1d/d",
|
"gte": "now-1d/d",
|
||||||
"lt" : "now/d"
|
"lt": "now/d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ GET /_search
|
||||||
"regexp": {
|
"regexp": {
|
||||||
"user": {
|
"user": {
|
||||||
"value": "k.*y",
|
"value": "k.*y",
|
||||||
"flags" : "ALL",
|
"flags": "ALL",
|
||||||
"max_determinized_states": 10000,
|
"max_determinized_states": 10000,
|
||||||
"rewrite": "constant_score"
|
"rewrite": "constant_score"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ WARNING: Using scripts can result in slower search speeds. See
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"script" : {
|
"script": {
|
||||||
"script" : {
|
"script": {
|
||||||
"source": "doc['num1'].value > 1",
|
"source": "doc['num1'].value > 1",
|
||||||
"lang": "painless"
|
"lang": "painless"
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,14 @@ in the script's `params` parameter. For example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"filter" : {
|
"filter": {
|
||||||
"script" : {
|
"script": {
|
||||||
"script" : {
|
"script": {
|
||||||
"source" : "doc['num1'].value > params.param1",
|
"source": "doc['num1'].value > params.param1",
|
||||||
"lang" : "painless",
|
"lang": "painless",
|
||||||
"params" : {
|
"params": {
|
||||||
"param1" : 5
|
"param1": 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,13 @@ The following `script_score` query assigns each returned document a score equal
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"script_score" : {
|
"script_score": {
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "message": "elasticsearch" }
|
"match": { "message": "elasticsearch" }
|
||||||
},
|
},
|
||||||
"script" : {
|
"script": {
|
||||||
"source" : "doc['likes'].value / 10 "
|
"source": "doc['likes'].value / 10 "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,13 +345,13 @@ Using an <<search-explain, explain request>> provides an explanation of how the
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /twitter/_explain/0
|
GET /twitter/_explain/0
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"script_score" : {
|
"script_score": {
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "message": "elasticsearch" }
|
"match": { "message": "elasticsearch" }
|
||||||
},
|
},
|
||||||
"script" : {
|
"script": {
|
||||||
"source" : """
|
"source": """
|
||||||
long likes = doc['likes'].value;
|
long likes = doc['likes'].value;
|
||||||
double normalizedLikes = likes / 10;
|
double normalizedLikes = likes / 10;
|
||||||
if (explanation != null) {
|
if (explanation != null) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ PUT /example/_doc/1?refresh=wait_for
|
||||||
"name": "Lucky Landing",
|
"name": "Lucky Landing",
|
||||||
"geometry": {
|
"geometry": {
|
||||||
"type": "point",
|
"type": "point",
|
||||||
"coordinates": [1355.400544, 5255.530286]
|
"coordinates": [ 1355.400544, 5255.530286 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -55,12 +55,12 @@ The following query will find the point using the Elasticsearch's
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /example/_search
|
GET /example/_search
|
||||||
{
|
{
|
||||||
"query":{
|
"query": {
|
||||||
"shape": {
|
"shape": {
|
||||||
"geometry": {
|
"geometry": {
|
||||||
"shape": {
|
"shape": {
|
||||||
"type": "envelope",
|
"type": "envelope",
|
||||||
"coordinates" : [[1355.0, 5355.0], [1400.0, 5200.0]]
|
"coordinates": [ [ 1355.0, 5355.0 ], [ 1400.0, 5200.0 ] ]
|
||||||
},
|
},
|
||||||
"relation": "within"
|
"relation": "within"
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ PUT /shapes/_doc/footprint
|
||||||
{
|
{
|
||||||
"geometry": {
|
"geometry": {
|
||||||
"type": "envelope",
|
"type": "envelope",
|
||||||
"coordinates" : [[1355.0, 5355.0], [1400.0, 5200.0]]
|
"coordinates": [ [ 1355.0, 5355.0 ], [ 1400.0, 5200.0 ] ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,9 @@ value. For example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"simple_query_string" : {
|
"simple_query_string": {
|
||||||
"fields" : ["content"],
|
"fields": [ "content" ],
|
||||||
"query" : "foo bar -baz"
|
"query": "foo bar -baz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,9 +185,9 @@ and `PREFIX`.
|
||||||
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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,18 @@ query maps to Lucene `SpanContainingQuery`. Here is an example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_containing" : {
|
"span_containing": {
|
||||||
"little" : {
|
"little": {
|
||||||
"span_term" : { "field1" : "foo" }
|
"span_term": { "field1": "foo" }
|
||||||
},
|
},
|
||||||
"big" : {
|
"big": {
|
||||||
"span_near" : {
|
"span_near": {
|
||||||
"clauses" : [
|
"clauses": [
|
||||||
{ "span_term" : { "field1" : "bar" } },
|
{ "span_term": { "field1": "bar" } },
|
||||||
{ "span_term" : { "field1" : "baz" } }
|
{ "span_term": { "field1": "baz" } }
|
||||||
],
|
],
|
||||||
"slop" : 5,
|
"slop": 5,
|
||||||
"in_order" : true
|
"in_order": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ it can be nested. Example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_multi":{
|
"span_multi": {
|
||||||
"match":{
|
"match": {
|
||||||
"prefix" : { "user" : { "value" : "ki" } }
|
"prefix": { "user": { "value": "ki" } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,9 @@ A boost can also be associated with the query:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_multi":{
|
"span_multi": {
|
||||||
"match":{
|
"match": {
|
||||||
"prefix" : { "user" : { "value" : "ki", "boost" : 1.08 } }
|
"prefix": { "user": { "value": "ki", "boost": 1.08 } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ matches are required to be in-order. The span near query maps to Lucene
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_near" : {
|
"span_near": {
|
||||||
"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" } }
|
||||||
],
|
],
|
||||||
"slop" : 12,
|
"slop": 12,
|
||||||
"in_order" : false
|
"in_order": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,18 @@ query maps to Lucene `SpanNotQuery`. Here is an example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_not" : {
|
"span_not": {
|
||||||
"include" : {
|
"include": {
|
||||||
"span_term" : { "field1" : "hoya" }
|
"span_term": { "field1": "hoya" }
|
||||||
},
|
},
|
||||||
"exclude" : {
|
"exclude": {
|
||||||
"span_near" : {
|
"span_near": {
|
||||||
"clauses" : [
|
"clauses": [
|
||||||
{ "span_term" : { "field1" : "la" } },
|
{ "span_term": { "field1": "la" } },
|
||||||
{ "span_term" : { "field1" : "hoya" } }
|
{ "span_term": { "field1": "hoya" } }
|
||||||
],
|
],
|
||||||
"slop" : 0,
|
"slop": 0,
|
||||||
"in_order" : true
|
"in_order": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,18 @@ query maps to Lucene `SpanWithinQuery`. Here is an example:
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"span_within" : {
|
"span_within": {
|
||||||
"little" : {
|
"little": {
|
||||||
"span_term" : { "field1" : "foo" }
|
"span_term": { "field1": "foo" }
|
||||||
},
|
},
|
||||||
"big" : {
|
"big": {
|
||||||
"span_near" : {
|
"span_near": {
|
||||||
"clauses" : [
|
"clauses": [
|
||||||
{ "span_term" : { "field1" : "bar" } },
|
{ "span_term": { "field1": "bar" } },
|
||||||
{ "span_term" : { "field1" : "baz" } }
|
{ "span_term": { "field1": "baz" } }
|
||||||
],
|
],
|
||||||
"slop" : 5,
|
"slop": 5,
|
||||||
"in_order" : true
|
"in_order": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,9 +94,9 @@ To see the difference in search results, try the following example.
|
||||||
----
|
----
|
||||||
PUT my_index
|
PUT my_index
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"full_text" : { "type" : "text" }
|
"full_text": { "type": "text" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ or `elasticsearch`.
|
||||||
----
|
----
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"terms" : {
|
"terms": {
|
||||||
"user" : ["kimchy", "elasticsearch"],
|
"user": [ "kimchy", "elasticsearch" ],
|
||||||
"boost" : 1.0
|
"boost": 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,9 +127,9 @@ To see how terms lookup works, try the following example.
|
||||||
----
|
----
|
||||||
PUT my_index
|
PUT my_index
|
||||||
{
|
{
|
||||||
"mappings" : {
|
"mappings": {
|
||||||
"properties" : {
|
"properties": {
|
||||||
"color" : { "type" : "keyword" }
|
"color": { "type": "keyword" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ search.
|
||||||
PUT /job-candidates/_doc/1?refresh
|
PUT /job-candidates/_doc/1?refresh
|
||||||
{
|
{
|
||||||
"name": "Jane Smith",
|
"name": "Jane Smith",
|
||||||
"programming_languages": ["c++", "java"],
|
"programming_languages": [ "c++", "java" ],
|
||||||
"required_matches": 2
|
"required_matches": 2
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
@ -108,7 +108,7 @@ PUT /job-candidates/_doc/1?refresh
|
||||||
PUT /job-candidates/_doc/2?refresh
|
PUT /job-candidates/_doc/2?refresh
|
||||||
{
|
{
|
||||||
"name": "Jason Response",
|
"name": "Jason Response",
|
||||||
"programming_languages": ["java", "php"],
|
"programming_languages": [ "java", "php" ],
|
||||||
"required_matches": 2
|
"required_matches": 2
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
@ -139,7 +139,7 @@ GET /job-candidates/_search
|
||||||
"query": {
|
"query": {
|
||||||
"terms_set": {
|
"terms_set": {
|
||||||
"programming_languages": {
|
"programming_languages": {
|
||||||
"terms": ["c++", "java", "php"],
|
"terms": [ "c++", "java", "php" ],
|
||||||
"minimum_should_match_field": "required_matches"
|
"minimum_should_match_field": "required_matches"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ GET /job-candidates/_search
|
||||||
"query": {
|
"query": {
|
||||||
"terms_set": {
|
"terms_set": {
|
||||||
"programming_languages": {
|
"programming_languages": {
|
||||||
"terms": ["c++", "java", "php"],
|
"terms": [ "c++", "java", "php" ],
|
||||||
"minimum_should_match_script": {
|
"minimum_should_match_script": {
|
||||||
"source": "Math.min(params.num_terms, doc['required_matches'].value)"
|
"source": "Math.min(params.num_terms, doc['required_matches'].value)"
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,9 +10,9 @@ A query that accepts any other query as base64 encoded string.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"wrapper": {
|
"wrapper": {
|
||||||
"query" : "eyJ0ZXJtIiA6IHsgInVzZXIiIDogIktpbWNoeSIgfX0=" <1>
|
"query": "eyJ0ZXJtIiA6IHsgInVzZXIiIDogIktpbWNoeSIgfX0=" <1>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,54 +96,54 @@ The API yields the following response:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
----
|
----
|
||||||
{
|
{
|
||||||
"jobs" : [
|
"jobs": [
|
||||||
{
|
{
|
||||||
"config" : {
|
"config": {
|
||||||
"id" : "sensor",
|
"id": "sensor",
|
||||||
"index_pattern" : "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index" : "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron" : "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram" : {
|
"date_histogram": {
|
||||||
"fixed_interval" : "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d",
|
"delay": "7d",
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"time_zone": "UTC"
|
"time_zone": "UTC"
|
||||||
},
|
},
|
||||||
"terms" : {
|
"terms": {
|
||||||
"fields" : [
|
"fields": [
|
||||||
"node"
|
"node"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field" : "temperature",
|
"field": "temperature",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
"sum"
|
"sum"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field" : "voltage",
|
"field": "voltage",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"avg"
|
"avg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timeout" : "20s",
|
"timeout": "20s",
|
||||||
"page_size" : 1000
|
"page_size": 1000
|
||||||
},
|
},
|
||||||
"status" : {
|
"status": {
|
||||||
"job_state" : "stopped",
|
"job_state": "stopped",
|
||||||
"upgraded_doc_id": true
|
"upgraded_doc_id": true
|
||||||
},
|
},
|
||||||
"stats" : {
|
"stats": {
|
||||||
"pages_processed" : 0,
|
"pages_processed": 0,
|
||||||
"documents_processed" : 0,
|
"documents_processed": 0,
|
||||||
"rollups_indexed" : 0,
|
"rollups_indexed": 0,
|
||||||
"trigger_count" : 0,
|
"trigger_count": 0,
|
||||||
"index_failures": 0,
|
"index_failures": 0,
|
||||||
"index_time_in_ms": 0,
|
"index_time_in_ms": 0,
|
||||||
"index_total": 0,
|
"index_total": 0,
|
||||||
|
@ -168,25 +168,25 @@ PUT _rollup/job/sensor2 <1>
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -202,54 +202,54 @@ Which will yield the following response:
|
||||||
[source,js]
|
[source,js]
|
||||||
----
|
----
|
||||||
{
|
{
|
||||||
"jobs" : [
|
"jobs": [
|
||||||
{
|
{
|
||||||
"config" : {
|
"config": {
|
||||||
"id" : "sensor2",
|
"id": "sensor2",
|
||||||
"index_pattern" : "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index" : "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron" : "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram" : {
|
"date_histogram": {
|
||||||
"fixed_interval" : "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d",
|
"delay": "7d",
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"time_zone": "UTC"
|
"time_zone": "UTC"
|
||||||
},
|
},
|
||||||
"terms" : {
|
"terms": {
|
||||||
"fields" : [
|
"fields": [
|
||||||
"node"
|
"node"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field" : "temperature",
|
"field": "temperature",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
"sum"
|
"sum"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field" : "voltage",
|
"field": "voltage",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"avg"
|
"avg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timeout" : "20s",
|
"timeout": "20s",
|
||||||
"page_size" : 1000
|
"page_size": 1000
|
||||||
},
|
},
|
||||||
"status" : {
|
"status": {
|
||||||
"job_state" : "stopped",
|
"job_state": "stopped",
|
||||||
"upgraded_doc_id": true
|
"upgraded_doc_id": true
|
||||||
},
|
},
|
||||||
"stats" : {
|
"stats": {
|
||||||
"pages_processed" : 0,
|
"pages_processed": 0,
|
||||||
"documents_processed" : 0,
|
"documents_processed": 0,
|
||||||
"rollups_indexed" : 0,
|
"rollups_indexed": 0,
|
||||||
"trigger_count" : 0,
|
"trigger_count": 0,
|
||||||
"index_failures": 0,
|
"index_failures": 0,
|
||||||
"index_time_in_ms": 0,
|
"index_time_in_ms": 0,
|
||||||
"index_total": 0,
|
"index_total": 0,
|
||||||
|
@ -261,52 +261,52 @@ Which will yield the following response:
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"config" : {
|
"config": {
|
||||||
"id" : "sensor",
|
"id": "sensor",
|
||||||
"index_pattern" : "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index" : "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron" : "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram" : {
|
"date_histogram": {
|
||||||
"fixed_interval" : "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d",
|
"delay": "7d",
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"time_zone": "UTC"
|
"time_zone": "UTC"
|
||||||
},
|
},
|
||||||
"terms" : {
|
"terms": {
|
||||||
"fields" : [
|
"fields": [
|
||||||
"node"
|
"node"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field" : "temperature",
|
"field": "temperature",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
"sum"
|
"sum"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field" : "voltage",
|
"field": "voltage",
|
||||||
"metrics" : [
|
"metrics": [
|
||||||
"avg"
|
"avg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timeout" : "20s",
|
"timeout": "20s",
|
||||||
"page_size" : 1000
|
"page_size": 1000
|
||||||
},
|
},
|
||||||
"status" : {
|
"status": {
|
||||||
"job_state" : "stopped",
|
"job_state": "stopped",
|
||||||
"upgraded_doc_id": true
|
"upgraded_doc_id": true
|
||||||
},
|
},
|
||||||
"stats" : {
|
"stats": {
|
||||||
"pages_processed" : 0,
|
"pages_processed": 0,
|
||||||
"documents_processed" : 0,
|
"documents_processed": 0,
|
||||||
"rollups_indexed" : 0,
|
"rollups_indexed": 0,
|
||||||
"trigger_count" : 0,
|
"trigger_count": 0,
|
||||||
"index_failures": 0,
|
"index_failures": 0,
|
||||||
"index_time_in_ms": 0,
|
"index_time_in_ms": 0,
|
||||||
"index_total": 0,
|
"index_total": 0,
|
||||||
|
|
|
@ -250,25 +250,25 @@ PUT _rollup/job/sensor
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : { <1>
|
"groups": { <1>
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [ <2>
|
"metrics": [ <2>
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,25 +60,25 @@ PUT _rollup/job/sensor
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,25 +56,25 @@ PUT _rollup/job/sensor
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,25 +82,25 @@ PUT _rollup/job/sensor
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -187,16 +187,16 @@ GET sensor_rollup/_rollup_search
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
----
|
----
|
||||||
{
|
{
|
||||||
"error" : {
|
"error": {
|
||||||
"root_cause" : [
|
"root_cause": [
|
||||||
{
|
{
|
||||||
"type" : "illegal_argument_exception",
|
"type": "illegal_argument_exception",
|
||||||
"reason" : "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
||||||
"stack_trace": ...
|
"stack_trace": ...
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type" : "illegal_argument_exception",
|
"type": "illegal_argument_exception",
|
||||||
"reason" : "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
||||||
"stack_trace": ...
|
"stack_trace": ...
|
||||||
},
|
},
|
||||||
"status": 400
|
"status": 400
|
||||||
|
|
|
@ -38,24 +38,24 @@ PUT _rollup/job/sensor
|
||||||
"index_pattern": "sensor-*",
|
"index_pattern": "sensor-*",
|
||||||
"rollup_index": "sensor_rollup",
|
"rollup_index": "sensor_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "60m"
|
"fixed_interval": "60m"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node"]
|
"fields": [ "node" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "voltage",
|
"field": "voltage",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,16 @@ The response will tell you that the field and aggregation were not possible, bec
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
----
|
----
|
||||||
{
|
{
|
||||||
"error" : {
|
"error": {
|
||||||
"root_cause" : [
|
"root_cause": [
|
||||||
{
|
{
|
||||||
"type" : "illegal_argument_exception",
|
"type": "illegal_argument_exception",
|
||||||
"reason" : "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
||||||
"stack_trace": ...
|
"stack_trace": ...
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type" : "illegal_argument_exception",
|
"type": "illegal_argument_exception",
|
||||||
"reason" : "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
|
||||||
"stack_trace": ...
|
"stack_trace": ...
|
||||||
},
|
},
|
||||||
"status": 400
|
"status": 400
|
||||||
|
|
|
@ -214,25 +214,25 @@ PUT _rollup/job/combined
|
||||||
"index_pattern": "data-*",
|
"index_pattern": "data-*",
|
||||||
"rollup_index": "data_rollup",
|
"rollup_index": "data_rollup",
|
||||||
"cron": "*/30 * * * * ?",
|
"cron": "*/30 * * * * ?",
|
||||||
"page_size" :1000,
|
"page_size": 1000,
|
||||||
"groups" : {
|
"groups": {
|
||||||
"date_histogram": {
|
"date_histogram": {
|
||||||
"field": "timestamp",
|
"field": "timestamp",
|
||||||
"fixed_interval": "1h",
|
"fixed_interval": "1h",
|
||||||
"delay": "7d"
|
"delay": "7d"
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"fields": ["node", "title"]
|
"fields": [ "node", "title" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"field": "temperature",
|
"field": "temperature",
|
||||||
"metrics": ["min", "max", "sum"]
|
"metrics": [ "min", "max", "sum" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "price",
|
"field": "price",
|
||||||
"metrics": ["avg"]
|
"metrics": [ "avg" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,14 @@ only the relevant shard:
|
||||||
POST /twitter/_search?routing=kimchy
|
POST /twitter/_search?routing=kimchy
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"must" : {
|
"must": {
|
||||||
"query_string" : {
|
"query_string": {
|
||||||
"query" : "some query string here"
|
"query": "some query string here"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter" : {
|
"filter": {
|
||||||
"term" : { "user" : "kimchy" }
|
"term": { "user": "kimchy" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ parameters and request body as the <<search-search,search API>>.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST /sales*/_async_search?size=0
|
POST /sales*/_async_search?size=0
|
||||||
{
|
{
|
||||||
"sort" : [
|
"sort": [
|
||||||
{ "date" : {"order" : "asc"} }
|
{ "date": { "order": "asc" } }
|
||||||
],
|
],
|
||||||
"aggs" : {
|
"aggs": {
|
||||||
"sale_date" : {
|
"sale_date": {
|
||||||
"date_histogram" : {
|
"date_histogram": {
|
||||||
"field" : "date",
|
"field": "date",
|
||||||
"calendar_interval": "1d"
|
"calendar_interval": "1d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,12 @@ index for a certain user. The API returns the following response:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"count" : 1,
|
"count": 1,
|
||||||
"_shards" : {
|
"_shards": {
|
||||||
"total" : 1,
|
"total": 1,
|
||||||
"successful" : 1,
|
"successful": 1,
|
||||||
"skipped" : 0,
|
"skipped": 0,
|
||||||
"failed" : 0
|
"failed": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
|
@ -134,20 +134,20 @@ The API returns the following response:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"indices": ["index1", "index2", "index3", "index4", "index5"],
|
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
|
||||||
"fields": {
|
"fields": {
|
||||||
"rating": { <1>
|
"rating": { <1>
|
||||||
"long": {
|
"long": {
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"aggregatable": false,
|
"aggregatable": false,
|
||||||
"indices": ["index1", "index2"],
|
"indices": [ "index1", "index2" ],
|
||||||
"non_aggregatable_indices": ["index1"] <2>
|
"non_aggregatable_indices": [ "index1" ] <2>
|
||||||
},
|
},
|
||||||
"keyword": {
|
"keyword": {
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"aggregatable": true,
|
"aggregatable": true,
|
||||||
"indices": ["index3", "index4"],
|
"indices": [ "index3", "index4" ],
|
||||||
"non_searchable_indices": ["index4"] <3>
|
"non_searchable_indices": [ "index4" ] <3>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": { <4>
|
"title": { <4>
|
||||||
|
@ -183,35 +183,35 @@ in some indices but not all:
|
||||||
[source,console-result]
|
[source,console-result]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"indices": ["index1", "index2", "index3"],
|
"indices": [ "index1", "index2", "index3" ],
|
||||||
"fields": {
|
"fields": {
|
||||||
"rating": {
|
"rating": {
|
||||||
"long": {
|
"long": {
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"aggregatable": false,
|
"aggregatable": false,
|
||||||
"indices": ["index1", "index2"],
|
"indices": [ "index1", "index2" ],
|
||||||
"non_aggregatable_indices": ["index1"]
|
"non_aggregatable_indices": [ "index1" ]
|
||||||
},
|
},
|
||||||
"keyword": {
|
"keyword": {
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"aggregatable": true,
|
"aggregatable": true,
|
||||||
"indices": ["index3", "index4"],
|
"indices": [ "index3", "index4" ],
|
||||||
"non_searchable_indices": ["index4"]
|
"non_searchable_indices": [ "index4" ]
|
||||||
},
|
},
|
||||||
"unmapped": { <1>
|
"unmapped": { <1>
|
||||||
"indices": ["index5"],
|
"indices": [ "index5" ],
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"aggregatable": false
|
"aggregatable": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"text": {
|
"text": {
|
||||||
"indices": ["index1", "index2", "index3", "index4"],
|
"indices": [ "index1", "index2", "index3", "index4" ],
|
||||||
"searchable": true,
|
"searchable": true,
|
||||||
"aggregatable": false
|
"aggregatable": false
|
||||||
},
|
},
|
||||||
"unmapped": { <2>
|
"unmapped": { <2>
|
||||||
"indices": ["index5"]
|
"indices": [ "index5" ],
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"aggregatable": false
|
"aggregatable": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,25 +120,25 @@ GET /my_index/_rank_eval
|
||||||
{
|
{
|
||||||
"id": "amsterdam_query", <1>
|
"id": "amsterdam_query", <1>
|
||||||
"request": { <2>
|
"request": { <2>
|
||||||
"query": { "match": { "text": "amsterdam" }}
|
"query": { "match": { "text": "amsterdam" } }
|
||||||
},
|
},
|
||||||
"ratings": [ <3>
|
"ratings": [ <3>
|
||||||
{ "_index": "my_index", "_id": "doc1", "rating": 0 },
|
{ "_index": "my_index", "_id": "doc1", "rating": 0 },
|
||||||
{ "_index": "my_index", "_id": "doc2", "rating": 3},
|
{ "_index": "my_index", "_id": "doc2", "rating": 3 },
|
||||||
{ "_index": "my_index", "_id": "doc3", "rating": 1 }
|
{ "_index": "my_index", "_id": "doc3", "rating": 1 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "berlin_query",
|
"id": "berlin_query",
|
||||||
"request": {
|
"request": {
|
||||||
"query": { "match": { "text": "berlin" }}
|
"query": { "match": { "text": "berlin" } }
|
||||||
},
|
},
|
||||||
"ratings": [
|
"ratings": [
|
||||||
{ "_index": "my_index", "_id": "doc1", "rating": 1 }
|
{ "_index": "my_index", "_id": "doc1", "rating": 1 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
-----------------------------
|
-----------------------------
|
||||||
// NOTCONSOLE
|
// NOTCONSOLE
|
||||||
|
|
||||||
|
@ -235,12 +235,12 @@ GET /twitter/_rank_eval
|
||||||
"requests": [
|
"requests": [
|
||||||
{
|
{
|
||||||
"id": "JFK query",
|
"id": "JFK query",
|
||||||
"request": { "query": { "match_all": {}}},
|
"request": { "query": { "match_all": {} } },
|
||||||
"ratings": []
|
"ratings": []
|
||||||
}],
|
} ],
|
||||||
"metric": {
|
"metric": {
|
||||||
"precision": {
|
"precision": {
|
||||||
"k" : 20,
|
"k": 20,
|
||||||
"relevant_rating_threshold": 1,
|
"relevant_rating_threshold": 1,
|
||||||
"ignore_unlabeled": false
|
"ignore_unlabeled": false
|
||||||
}
|
}
|
||||||
|
@ -290,12 +290,12 @@ GET /twitter/_rank_eval
|
||||||
"requests": [
|
"requests": [
|
||||||
{
|
{
|
||||||
"id": "JFK query",
|
"id": "JFK query",
|
||||||
"request": { "query": { "match_all": {}}},
|
"request": { "query": { "match_all": {} } },
|
||||||
"ratings": []
|
"ratings": []
|
||||||
}],
|
} ],
|
||||||
"metric": {
|
"metric": {
|
||||||
"recall": {
|
"recall": {
|
||||||
"k" : 20,
|
"k": 20,
|
||||||
"relevant_rating_threshold": 1
|
"relevant_rating_threshold": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,13 +331,13 @@ GET /twitter/_rank_eval
|
||||||
"requests": [
|
"requests": [
|
||||||
{
|
{
|
||||||
"id": "JFK query",
|
"id": "JFK query",
|
||||||
"request": { "query": { "match_all": {}}},
|
"request": { "query": { "match_all": {} } },
|
||||||
"ratings": []
|
"ratings": []
|
||||||
}],
|
} ],
|
||||||
"metric": {
|
"metric": {
|
||||||
"mean_reciprocal_rank": {
|
"mean_reciprocal_rank": {
|
||||||
"k" : 20,
|
"k": 20,
|
||||||
"relevant_rating_threshold" : 1
|
"relevant_rating_threshold": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,12 +375,12 @@ GET /twitter/_rank_eval
|
||||||
"requests": [
|
"requests": [
|
||||||
{
|
{
|
||||||
"id": "JFK query",
|
"id": "JFK query",
|
||||||
"request": { "query": { "match_all": {}}},
|
"request": { "query": { "match_all": {} } },
|
||||||
"ratings": []
|
"ratings": []
|
||||||
}],
|
} ],
|
||||||
"metric": {
|
"metric": {
|
||||||
"dcg": {
|
"dcg": {
|
||||||
"k" : 20,
|
"k": 20,
|
||||||
"normalize": false
|
"normalize": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,13 +431,13 @@ GET /twitter/_rank_eval
|
||||||
"requests": [
|
"requests": [
|
||||||
{
|
{
|
||||||
"id": "JFK query",
|
"id": "JFK query",
|
||||||
"request": { "query": { "match_all": {}}},
|
"request": { "query": { "match_all": {} } },
|
||||||
"ratings": []
|
"ratings": []
|
||||||
}],
|
} ],
|
||||||
"metric": {
|
"metric": {
|
||||||
"expected_reciprocal_rank": {
|
"expected_reciprocal_rank": {
|
||||||
"maximum_relevance" : 3,
|
"maximum_relevance": 3,
|
||||||
"k" : 20
|
"k": 20
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ potential errors of individual queries. The response has the following format:
|
||||||
{
|
{
|
||||||
"_index": "my_index",
|
"_index": "my_index",
|
||||||
"_id": "1960795"
|
"_id": "1960795"
|
||||||
}, [...]
|
}, ...
|
||||||
],
|
],
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
|
@ -486,18 +486,18 @@ potential errors of individual queries. The response has the following format:
|
||||||
"_score": 7.0556192
|
"_score": 7.0556192
|
||||||
},
|
},
|
||||||
"rating": 1
|
"rating": 1
|
||||||
}, [...]
|
}, ...
|
||||||
],
|
],
|
||||||
"metric_details": { <6>
|
"metric_details": { <6>
|
||||||
"precision" : {
|
"precision": {
|
||||||
"relevant_docs_retrieved": 6,
|
"relevant_docs_retrieved": 6,
|
||||||
"docs_retrieved": 10
|
"docs_retrieved": 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"my_query_id2" : { [...] }
|
"my_query_id2": { [... ] }
|
||||||
},
|
},
|
||||||
"failures": { [...] }
|
"failures": { [... ] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
|
@ -14,10 +14,10 @@ GET /twitter/_search
|
||||||
"message": "elasticsearch"
|
"message": "elasticsearch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"collapse" : {
|
"collapse": {
|
||||||
"field" : "user" <1>
|
"field": "user" <1>
|
||||||
},
|
},
|
||||||
"sort": ["likes"], <2>
|
"sort": [ "likes" ], <2>
|
||||||
"from": 10 <3>
|
"from": 10 <3>
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -48,16 +48,16 @@ GET /twitter/_search
|
||||||
"message": "elasticsearch"
|
"message": "elasticsearch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"collapse" : {
|
"collapse": {
|
||||||
"field" : "user", <1>
|
"field": "user", <1>
|
||||||
"inner_hits": {
|
"inner_hits": {
|
||||||
"name": "last_tweets", <2>
|
"name": "last_tweets", <2>
|
||||||
"size": 5, <3>
|
"size": 5, <3>
|
||||||
"sort": [{ "date": "asc" }] <4>
|
"sort": [ { "date": "asc" } ] <4>
|
||||||
},
|
},
|
||||||
"max_concurrent_group_searches": 4 <5>
|
"max_concurrent_group_searches": 4 <5>
|
||||||
},
|
},
|
||||||
"sort": ["likes"]
|
"sort": [ "likes" ]
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[setup:twitter]
|
// TEST[setup:twitter]
|
||||||
|
@ -82,22 +82,22 @@ GET /twitter/_search
|
||||||
"message": "elasticsearch"
|
"message": "elasticsearch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"collapse" : {
|
"collapse": {
|
||||||
"field" : "user", <1>
|
"field": "user", <1>
|
||||||
"inner_hits": [
|
"inner_hits": [
|
||||||
{
|
{
|
||||||
"name": "most_liked", <2>
|
"name": "most_liked", <2>
|
||||||
"size": 3,
|
"size": 3,
|
||||||
"sort": ["likes"]
|
"sort": [ "likes" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "most_recent", <3>
|
"name": "most_recent", <3>
|
||||||
"size": 3,
|
"size": 3,
|
||||||
"sort": [{ "date": "asc" }]
|
"sort": [ { "date": "asc" } ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sort": ["likes"]
|
"sort": [ "likes" ]
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TEST[setup:twitter]
|
// TEST[setup:twitter]
|
||||||
|
@ -133,11 +133,11 @@ GET /twitter/_search
|
||||||
"message": "elasticsearch"
|
"message": "elasticsearch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"collapse" : {
|
"collapse": {
|
||||||
"field" : "country",
|
"field": "country",
|
||||||
"inner_hits" : {
|
"inner_hits": {
|
||||||
"name": "by_location",
|
"name": "by_location",
|
||||||
"collapse" : {"field" : "user"},
|
"collapse": { "field": "user" },
|
||||||
"size": 3
|
"size": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,23 +158,23 @@ Response:
|
||||||
"_id": "9",
|
"_id": "9",
|
||||||
"_score": ...,
|
"_score": ...,
|
||||||
"_source": {...},
|
"_source": {...},
|
||||||
"fields": {"country": ["UK"]},
|
"fields": { "country": [ "UK" ] },
|
||||||
"inner_hits":{
|
"inner_hits": {
|
||||||
"by_location": {
|
"by_location": {
|
||||||
"hits": {
|
"hits": {
|
||||||
...,
|
...,
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user124"]}
|
"fields": { "user": [ "user124" ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user589"]}
|
"fields": { "user": [ "user589" ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user001"]}
|
"fields": { "user": [ "user001" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -186,32 +186,32 @@ Response:
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "1",
|
"_id": "1",
|
||||||
"_score": ..,
|
"_score": ..,
|
||||||
"_source": {...},
|
"_source": {...
|
||||||
"fields": {"country": ["Canada"]},
|
},
|
||||||
"inner_hits":{
|
"fields": { "country": [ "Canada" ] },
|
||||||
|
"inner_hits": {
|
||||||
"by_location": {
|
"by_location": {
|
||||||
"hits": {
|
"hits": {
|
||||||
...,
|
...,
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user444"]}
|
"fields": { "user": [ "user444" ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user1111"]}
|
"fields": { "user": [ "user1111" ] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"fields": {"user" : ["user999"]}
|
"fields": { "user": [ "user999" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
....
|
...
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
|
@ -91,9 +91,9 @@ PUT test_index
|
||||||
{
|
{
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"content" : {
|
"content": {
|
||||||
"type" : "text",
|
"type": "text",
|
||||||
"analyzer" : "english"
|
"analyzer": "english"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ the request body that specifies the `content` field:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "content": "kimchy" }
|
"match": { "content": "kimchy" }
|
||||||
},
|
},
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"fields" : {
|
"fields": {
|
||||||
"content" : {}
|
"content": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ highlighting would only take the search query into account.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match": {
|
"match": {
|
||||||
"comment": {
|
"comment": {
|
||||||
"query": "foo bar"
|
"query": "foo bar"
|
||||||
|
@ -319,7 +319,7 @@ GET /_search
|
||||||
"rescore": {
|
"rescore": {
|
||||||
"window_size": 50,
|
"window_size": 50,
|
||||||
"query": {
|
"query": {
|
||||||
"rescore_query" : {
|
"rescore_query": {
|
||||||
"match_phrase": {
|
"match_phrase": {
|
||||||
"comment": {
|
"comment": {
|
||||||
"query": "foo bar",
|
"query": "foo bar",
|
||||||
|
@ -327,16 +327,16 @@ GET /_search
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rescore_query_weight" : 10
|
"rescore_query_weight": 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"_source": false,
|
"_source": false,
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"order" : "score",
|
"order": "score",
|
||||||
"fields" : {
|
"fields": {
|
||||||
"comment" : {
|
"comment": {
|
||||||
"fragment_size" : 150,
|
"fragment_size": 150,
|
||||||
"number_of_fragments" : 3,
|
"number_of_fragments": 3,
|
||||||
"highlight_query": {
|
"highlight_query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"must": {
|
"must": {
|
||||||
|
@ -377,12 +377,12 @@ The following is an example that forces the use of the plain highlighter:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "user": "kimchy" }
|
"match": { "user": "kimchy" }
|
||||||
},
|
},
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"fields" : {
|
"fields": {
|
||||||
"comment" : {"type" : "plain"}
|
"comment": { "type": "plain" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,15 +526,15 @@ GET /_search
|
||||||
"query": {
|
"query": {
|
||||||
"query_string": {
|
"query_string": {
|
||||||
"query": "comment.plain:running scissors",
|
"query": "comment.plain:running scissors",
|
||||||
"fields": ["comment"]
|
"fields": [ "comment" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"highlight": {
|
"highlight": {
|
||||||
"order": "score",
|
"order": "score",
|
||||||
"fields": {
|
"fields": {
|
||||||
"comment": {
|
"comment": {
|
||||||
"matched_fields": ["comment", "comment.plain"],
|
"matched_fields": [ "comment", "comment.plain" ],
|
||||||
"type" : "fvh"
|
"type": "fvh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,15 +582,15 @@ GET /_search
|
||||||
"query": {
|
"query": {
|
||||||
"query_string": {
|
"query_string": {
|
||||||
"query": "running scissors",
|
"query": "running scissors",
|
||||||
"fields": ["comment", "comment.plain^10"]
|
"fields": [ "comment", "comment.plain^10" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"highlight": {
|
"highlight": {
|
||||||
"order": "score",
|
"order": "score",
|
||||||
"fields": {
|
"fields": {
|
||||||
"comment": {
|
"comment": {
|
||||||
"matched_fields": ["comment.plain"],
|
"matched_fields": [ "comment.plain" ],
|
||||||
"type" : "fvh"
|
"type": "fvh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,14 +745,14 @@ specified as it tries to break on a word boundary.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match": { "user": "kimchy" }
|
"match": { "user": "kimchy" }
|
||||||
},
|
},
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"fields" : {
|
"fields": {
|
||||||
"comment" : {
|
"comment": {
|
||||||
"fragment_size" : 150,
|
"fragment_size": 150,
|
||||||
"number_of_fragments" : 3,
|
"number_of_fragments": 3,
|
||||||
"no_match_size": 150
|
"no_match_size": 150
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -812,15 +812,15 @@ When using the `plain` highlighter, you can choose between the `simple` and
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET twitter/_search
|
GET twitter/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match_phrase": { "message": "number 1" }
|
"match_phrase": { "message": "number 1" }
|
||||||
},
|
},
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"fields" : {
|
"fields": {
|
||||||
"message" : {
|
"message": {
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
"fragment_size" : 15,
|
"fragment_size": 15,
|
||||||
"number_of_fragments" : 3,
|
"number_of_fragments": 3,
|
||||||
"fragmenter": "simple"
|
"fragmenter": "simple"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ Response:
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -870,15 +870,15 @@ Response:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET twitter/_search
|
GET twitter/_search
|
||||||
{
|
{
|
||||||
"query" : {
|
"query": {
|
||||||
"match_phrase": { "message": "number 1" }
|
"match_phrase": { "message": "number 1" }
|
||||||
},
|
},
|
||||||
"highlight" : {
|
"highlight": {
|
||||||
"fields" : {
|
"fields": {
|
||||||
"message" : {
|
"message": {
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
"fragment_size" : 15,
|
"fragment_size": 15,
|
||||||
"number_of_fragments" : 3,
|
"number_of_fragments": 3,
|
||||||
"fragmenter": "span"
|
"fragmenter": "span"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -894,7 +894,7 @@ Response:
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
|
|
@ -117,7 +117,7 @@ POST test/_search
|
||||||
"nested": {
|
"nested": {
|
||||||
"path": "comments",
|
"path": "comments",
|
||||||
"query": {
|
"query": {
|
||||||
"match": {"comments.number" : 2}
|
"match": { "comments.number": 2 }
|
||||||
},
|
},
|
||||||
"inner_hits": {} <1>
|
"inner_hits": {} <1>
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ An example of a response snippet that could be generated from the above search r
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -149,7 +149,7 @@ An example of a response snippet that could be generated from the above search r
|
||||||
"inner_hits": {
|
"inner_hits": {
|
||||||
"comments": { <1>
|
"comments": { <1>
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -240,11 +240,11 @@ POST test/_search
|
||||||
"nested": {
|
"nested": {
|
||||||
"path": "comments",
|
"path": "comments",
|
||||||
"query": {
|
"query": {
|
||||||
"match": {"comments.text" : "words"}
|
"match": { "comments.text": "words" }
|
||||||
},
|
},
|
||||||
"inner_hits": {
|
"inner_hits": {
|
||||||
"_source" : false,
|
"_source": false,
|
||||||
"docvalue_fields" : [
|
"docvalue_fields": [
|
||||||
"comments.text.keyword"
|
"comments.text.keyword"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ Response not included in text but tested for completeness sake.
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -277,7 +277,7 @@ Response not included in text but tested for completeness sake.
|
||||||
"inner_hits": {
|
"inner_hits": {
|
||||||
"comments": { <1>
|
"comments": { <1>
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -494,7 +494,7 @@ An example of a response snippet that could be generated from the above search r
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
@ -512,7 +512,7 @@ An example of a response snippet that could be generated from the above search r
|
||||||
"inner_hits": {
|
"inner_hits": {
|
||||||
"my_child": {
|
"my_child": {
|
||||||
"hits": {
|
"hits": {
|
||||||
"total" : {
|
"total": {
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"relation": "eq"
|
"relation": "eq"
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,15 +8,15 @@ Each filter and query can accept a `_name` in its top level definition.
|
||||||
GET /_search
|
GET /_search
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool" : {
|
"bool": {
|
||||||
"should" : [
|
"should": [
|
||||||
{"match" : { "name.first" : {"query" : "shay", "_name" : "first"} }},
|
{ "match": { "name.first": { "query": "shay", "_name": "first" } } },
|
||||||
{"match" : { "name.last" : {"query" : "banon", "_name" : "last"} }}
|
{ "match": { "name.last": { "query": "banon", "_name": "last" } } }
|
||||||
],
|
],
|
||||||
"filter" : {
|
"filter": {
|
||||||
"terms" : {
|
"terms": {
|
||||||
"name.last" : ["banon", "kimchy"],
|
"name.last": [ "banon", "kimchy" ],
|
||||||
"_name" : "test"
|
"_name": "test"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue