Deprecate _suggest endpoint in favour of _search (#20305)
* Replace _suggest endpoint to _search in docs In 5.0, the _suggest endpoint is just sugar for _search with suggestions specified. Users should move away from using the _suggest endpoint, as it is marked as deprecated in 5.x and will be removed in 6.0 * update docs to use _search endpoint instead of _suggest * Add deprecation logging to RestSuggestAction * Use search endpoint instead of suggest endpoint in rest tests
This commit is contained in:
parent
eaf82a6e7e
commit
cdd5fbe3a1
|
@ -56,10 +56,14 @@ public class RestSuggestAction extends BaseRestHandler {
|
||||||
SearchRequestParsers searchRequestParsers) {
|
SearchRequestParsers searchRequestParsers) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.searchRequestParsers = searchRequestParsers;
|
this.searchRequestParsers = searchRequestParsers;
|
||||||
controller.registerHandler(POST, "/_suggest", this);
|
controller.registerAsDeprecatedHandler(POST, "/_suggest", this,
|
||||||
controller.registerHandler(GET, "/_suggest", this);
|
"[POST /_suggest] is deprecated! Use [POST /_search] instead.", deprecationLogger);
|
||||||
controller.registerHandler(POST, "/{index}/_suggest", this);
|
controller.registerAsDeprecatedHandler(GET, "/_suggest", this,
|
||||||
controller.registerHandler(GET, "/{index}/_suggest", this);
|
"[GET /_suggest] is deprecated! Use [GET /_search] instead.", deprecationLogger);
|
||||||
|
controller.registerAsDeprecatedHandler(POST, "/{index}/_suggest", this,
|
||||||
|
"[POST /{index}/_suggest] is deprecated! Use [POST /{index}/_search] instead.", deprecationLogger);
|
||||||
|
controller.registerAsDeprecatedHandler(GET, "/{index}/_suggest", this,
|
||||||
|
"[GET /{index}/_suggest] is deprecated! Use [GET /{index}/_search] instead.", deprecationLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,8 +5,12 @@ The suggest feature suggests similar looking terms based on a provided
|
||||||
text by using a suggester. Parts of the suggest feature are still under
|
text by using a suggester. Parts of the suggest feature are still under
|
||||||
development.
|
development.
|
||||||
|
|
||||||
The suggest request part is either defined alongside the query part in a
|
The suggest request part is defined alongside the query part in a `_search`
|
||||||
`_search` request or via the REST `_suggest` endpoint.
|
request.
|
||||||
|
|
||||||
|
NOTE: `_suggest` endpoint has been deprecated in favour of using suggest via
|
||||||
|
`_search` endpoint. In 5.0, the `_search` endpoint has been optimized for
|
||||||
|
suggest only search requests.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -30,25 +34,6 @@ POST twitter/_search
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:twitter]
|
// TEST[setup:twitter]
|
||||||
|
|
||||||
Suggest requests executed against the `_suggest` endpoint should omit
|
|
||||||
the surrounding `suggest` element which is only used if the suggest
|
|
||||||
request is part of a search.
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
POST _suggest
|
|
||||||
{
|
|
||||||
"my-suggestion" : {
|
|
||||||
"text" : "tring out Elasticsearch",
|
|
||||||
"term" : {
|
|
||||||
"field" : "message"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
// CONSOLE
|
|
||||||
// TEST[setup:twitter]
|
|
||||||
|
|
||||||
Several suggestions can be specified per request. Each suggestion is
|
Several suggestions can be specified per request. Each suggestion is
|
||||||
identified with an arbitrary name. In the example below two suggestions
|
identified with an arbitrary name. In the example below two suggestions
|
||||||
are requested. Both `my-suggest-1` and `my-suggest-2` suggestions use
|
are requested. Both `my-suggest-1` and `my-suggest-2` suggestions use
|
||||||
|
@ -56,18 +41,20 @@ the `term` suggester, but have a different `text`.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _suggest
|
POST _search
|
||||||
{
|
{
|
||||||
"my-suggest-1" : {
|
"suggest": {
|
||||||
"text" : "tring out Elasticsearch",
|
"my-suggest-1" : {
|
||||||
"term" : {
|
"text" : "tring out Elasticsearch",
|
||||||
"field" : "message"
|
"term" : {
|
||||||
}
|
"field" : "message"
|
||||||
},
|
}
|
||||||
"my-suggest-2" : {
|
},
|
||||||
"text" : "kmichy",
|
"my-suggest-2" : {
|
||||||
"term" : {
|
"text" : "kmichy",
|
||||||
"field" : "user"
|
"term" : {
|
||||||
|
"field" : "user"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,27 +72,34 @@ in the suggest text and if found an arbitrary number of options.
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards": ...
|
"_shards": ...
|
||||||
"my-suggest-1": [ {
|
"hits": ...
|
||||||
"text": "tring",
|
"took": 2,
|
||||||
"offset": 0,
|
"timed_out": false,
|
||||||
"length": 5,
|
"suggest": {
|
||||||
"options": [ {"text": "trying", "score": 0.8, "freq": 1 } ]
|
"my-suggest-1": [ {
|
||||||
}, {
|
"text": "tring",
|
||||||
"text": "out",
|
"offset": 0,
|
||||||
"offset": 6,
|
"length": 5,
|
||||||
"length": 3,
|
"options": [ {"text": "trying", "score": 0.8, "freq": 1 } ]
|
||||||
"options": []
|
}, {
|
||||||
}, {
|
"text": "out",
|
||||||
"text": "elasticsearch",
|
"offset": 6,
|
||||||
"offset": 10,
|
"length": 3,
|
||||||
"length": 13,
|
"options": []
|
||||||
"options": []
|
}, {
|
||||||
} ],
|
"text": "elasticsearch",
|
||||||
"my-suggest-2": ...
|
"offset": 10,
|
||||||
|
"length": 13,
|
||||||
|
"options": []
|
||||||
|
} ],
|
||||||
|
"my-suggest-2": ...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"_shards": \.\.\./"_shards": "$body._shards",/]
|
// TESTRESPONSE[s/"_shards": \.\.\./"_shards": "$body._shards",/]
|
||||||
// TESTRESPONSE[s/"my-suggest-2": \.\.\./"my-suggest-2": "$body.my-suggest-2"/]
|
// TESTRESPONSE[s/"hits": .../"hits": "$body.hits",/]
|
||||||
|
// TESTRESPONSE[s/"took": 2,/"took": "$body.took",/]
|
||||||
|
// TESTRESPONSE[s/"my-suggest-2": \.\.\./"my-suggest-2": "$body.suggest.my-suggest-2"/]
|
||||||
|
|
||||||
|
|
||||||
Each options array contains an option object that includes the
|
Each options array contains an option object that includes the
|
||||||
|
@ -123,17 +117,19 @@ and applies to the `my-suggest-1` and `my-suggest-2` suggestions.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _suggest
|
POST _search
|
||||||
{
|
{
|
||||||
"text" : "tring out Elasticsearch",
|
"suggest": {
|
||||||
"my-suggest-1" : {
|
"text" : "tring out Elasticsearch",
|
||||||
"term" : {
|
"my-suggest-1" : {
|
||||||
"field" : "message"
|
"term" : {
|
||||||
}
|
"field" : "message"
|
||||||
},
|
}
|
||||||
"my-suggest-2" : {
|
},
|
||||||
"term" : {
|
"my-suggest-2" : {
|
||||||
"field" : "user"
|
"term" : {
|
||||||
|
"field" : "user"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,12 +152,14 @@ documents once deleted are never shown. This request:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST music/_suggest?pretty
|
POST music/_search?pretty
|
||||||
{
|
{
|
||||||
"song-suggest" : {
|
"suggest": {
|
||||||
"prefix" : "nir",
|
"song-suggest" : {
|
||||||
"completion" : {
|
"prefix" : "nir",
|
||||||
"field" : "suggest"
|
"completion" : {
|
||||||
|
"field" : "suggest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,24 +177,30 @@ returns this response:
|
||||||
"successful" : 5,
|
"successful" : 5,
|
||||||
"failed" : 0
|
"failed" : 0
|
||||||
},
|
},
|
||||||
"song-suggest" : [ {
|
"hits": ...
|
||||||
"text" : "nir",
|
"took": 2,
|
||||||
"offset" : 0,
|
"timed_out": false,
|
||||||
"length" : 3,
|
"suggest": {
|
||||||
"options" : [ {
|
"song-suggest" : [ {
|
||||||
"text" : "Nirvana",
|
"text" : "nir",
|
||||||
"_index": "music",
|
"offset" : 0,
|
||||||
"_type": "song",
|
"length" : 3,
|
||||||
"_id": "1",
|
"options" : [ {
|
||||||
"_score": 1.0,
|
"text" : "Nirvana",
|
||||||
"_source": {
|
"_index": "music",
|
||||||
"suggest": ["Nevermind", "Nirvana"]
|
"_type": "song",
|
||||||
}
|
"_id": "1",
|
||||||
|
"_score": 1.0,
|
||||||
|
"_source": {
|
||||||
|
"suggest": ["Nevermind", "Nirvana"]
|
||||||
|
}
|
||||||
|
} ]
|
||||||
} ]
|
} ]
|
||||||
} ]
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE
|
// TESTRESPONSE[s/"hits": .../"hits": "$body.hits",/]
|
||||||
|
// TESTRESPONSE[s/"took": 2,/"took": "$body.took",/]
|
||||||
|
|
||||||
|
|
||||||
IMPORTANT: `_source` meta-field must be enabled, which is the default
|
IMPORTANT: `_source` meta-field must be enabled, which is the default
|
||||||
|
@ -289,14 +297,16 @@ you can have a typo in your search and still get results back.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST music/_suggest?pretty
|
POST music/_search?pretty
|
||||||
{
|
{
|
||||||
"song-suggest" : {
|
"suggest": {
|
||||||
"prefix" : "nor",
|
"song-suggest" : {
|
||||||
"completion" : {
|
"prefix" : "nor",
|
||||||
"field" : "suggest",
|
"completion" : {
|
||||||
"fuzzy" : {
|
"field" : "suggest",
|
||||||
"fuzziness" : 2
|
"fuzzy" : {
|
||||||
|
"fuzziness" : 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,12 +356,14 @@ you can express a prefix as a regular expression
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST music/_suggest?pretty
|
POST music/_search?pretty
|
||||||
{
|
{
|
||||||
"song-suggest" : {
|
"suggest": {
|
||||||
"regex" : "n[ever|i]r",
|
"song-suggest" : {
|
||||||
"completion" : {
|
"regex" : "n[ever|i]r",
|
||||||
"field" : "suggest"
|
"completion" : {
|
||||||
|
"field" : "suggest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,15 +138,17 @@ filters suggestions by multiple categories:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST place/_suggest?pretty
|
POST place/_search?pretty
|
||||||
{
|
{
|
||||||
"suggest" : {
|
"suggest": {
|
||||||
"prefix" : "tim",
|
"place_suggestion" : {
|
||||||
"completion" : {
|
"prefix" : "tim",
|
||||||
"field" : "suggest",
|
"completion" : {
|
||||||
"size": 10,
|
"field" : "suggest",
|
||||||
"contexts": {
|
"size": 10,
|
||||||
"place_type": [ "cafe", "restaurants" ]
|
"contexts": {
|
||||||
|
"place_type": [ "cafe", "restaurants" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,18 +167,20 @@ suggestions associated with some categories:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST place/_suggest?pretty
|
POST place/_search?pretty
|
||||||
{
|
{
|
||||||
"suggest" : {
|
"suggest": {
|
||||||
"prefix" : "tim",
|
"place_suggestion" : {
|
||||||
"completion" : {
|
"prefix" : "tim",
|
||||||
"field" : "suggest",
|
"completion" : {
|
||||||
"size": 10,
|
"field" : "suggest",
|
||||||
"contexts": {
|
"size": 10,
|
||||||
"place_type": [ <1>
|
"contexts": {
|
||||||
{ "context" : "cafe" },
|
"place_type": [ <1>
|
||||||
{ "context" : "restaurants", "boost": 2 }
|
{ "context" : "cafe" },
|
||||||
]
|
{ "context" : "restaurants", "boost": 2 }
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,17 +279,19 @@ the encoded geohash of a geo point:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST place/_suggest
|
POST place/_search
|
||||||
{
|
{
|
||||||
"suggest" : {
|
"suggest": {
|
||||||
"prefix" : "tim",
|
"place_suggestion" : {
|
||||||
"completion" : {
|
"prefix" : "tim",
|
||||||
"field" : "suggest",
|
"completion" : {
|
||||||
"size": 10,
|
"field" : "suggest",
|
||||||
"contexts": {
|
"size": 10,
|
||||||
"location": {
|
"contexts": {
|
||||||
"lat": 43.662,
|
"location": {
|
||||||
"lon": -79.380
|
"lat": 43.662,
|
||||||
|
"lon": -79.380
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,28 +309,30 @@ than others, as shown by the following:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST place/_suggest?pretty
|
POST place/_search?pretty
|
||||||
{
|
{
|
||||||
"suggest" : {
|
"suggest": {
|
||||||
"prefix" : "tim",
|
"place_suggestion" : {
|
||||||
"completion" : {
|
"prefix" : "tim",
|
||||||
"field" : "suggest",
|
"completion" : {
|
||||||
"size": 10,
|
"field" : "suggest",
|
||||||
"contexts": {
|
"size": 10,
|
||||||
"location": [ <1>
|
"contexts": {
|
||||||
{
|
"location": [ <1>
|
||||||
"lat": 43.6624803,
|
{
|
||||||
"lon": -79.3863353,
|
|
||||||
"precision": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"context": {
|
|
||||||
"lat": 43.6624803,
|
"lat": 43.6624803,
|
||||||
"lon": -79.3863353
|
"lon": -79.3863353,
|
||||||
|
"precision": 2
|
||||||
},
|
},
|
||||||
"boost": 2
|
{
|
||||||
}
|
"context": {
|
||||||
]
|
"lat": 43.6624803,
|
||||||
|
"lon": -79.3863353
|
||||||
|
},
|
||||||
|
"boost": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,21 +84,23 @@ suggester in the same spot you'd use the `term` suggester:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _suggest
|
POST test/_search
|
||||||
{
|
{
|
||||||
"text": "noble prize",
|
"suggest": {
|
||||||
"simple_phrase": {
|
"text": "noble prize",
|
||||||
"phrase": {
|
"simple_phrase": {
|
||||||
"field": "title.trigram",
|
"phrase": {
|
||||||
"size": 1,
|
|
||||||
"gram_size": 3,
|
|
||||||
"direct_generator": [ {
|
|
||||||
"field": "title.trigram",
|
"field": "title.trigram",
|
||||||
"suggest_mode": "always"
|
"size": 1,
|
||||||
} ],
|
"gram_size": 3,
|
||||||
"highlight": {
|
"direct_generator": [ {
|
||||||
"pre_tag": "<em>",
|
"field": "title.trigram",
|
||||||
"post_tag": "</em>"
|
"suggest_mode": "always"
|
||||||
|
} ],
|
||||||
|
"highlight": {
|
||||||
|
"pre_tag": "<em>",
|
||||||
|
"post_tag": "</em>"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,21 +114,28 @@ The response contains suggestions scored by the most likely spell correction fir
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
"_shards": ...
|
"_shards": ...
|
||||||
"simple_phrase" : [
|
"hits": ...
|
||||||
{
|
"timed_out": false,
|
||||||
"text" : "noble prize",
|
"took": 3,
|
||||||
"offset" : 0,
|
"suggest": {
|
||||||
"length" : 11,
|
"simple_phrase" : [
|
||||||
"options" : [ {
|
{
|
||||||
"text" : "nobel prize",
|
"text" : "noble prize",
|
||||||
"highlighted": "<em>nobel</em> prize",
|
"offset" : 0,
|
||||||
"score" : 0.5962314
|
"length" : 11,
|
||||||
}]
|
"options" : [ {
|
||||||
}
|
"text" : "nobel prize",
|
||||||
]
|
"highlighted": "<em>nobel</em> prize",
|
||||||
|
"score" : 0.5962314
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// TESTRESPONSE[s/"_shards": .../"_shards": "$body._shards",/]
|
// TESTRESPONSE[s/"_shards": .../"_shards": "$body._shards",/]
|
||||||
|
// TESTRESPONSE[s/"hits": .../"hits": "$body.hits",/]
|
||||||
|
// TESTRESPONSE[s/"took": 3,/"took": "$body.took",/]
|
||||||
|
|
||||||
==== Basic Phrase suggest API parameters
|
==== Basic Phrase suggest API parameters
|
||||||
|
|
||||||
|
@ -217,28 +226,30 @@ The response contains suggestions scored by the most likely spell correction fir
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _suggest
|
POST _search
|
||||||
{
|
{
|
||||||
"text" : "noble prize",
|
"suggest": {
|
||||||
"simple_phrase" : {
|
"text" : "noble prize",
|
||||||
"phrase" : {
|
"simple_phrase" : {
|
||||||
"field" : "title.trigram",
|
"phrase" : {
|
||||||
"size" : 1,
|
"field" : "title.trigram",
|
||||||
"direct_generator" : [ {
|
"size" : 1,
|
||||||
"field" : "title.trigram",
|
"direct_generator" : [ {
|
||||||
"suggest_mode" : "always",
|
"field" : "title.trigram",
|
||||||
"min_word_length" : 1
|
"suggest_mode" : "always",
|
||||||
} ],
|
"min_word_length" : 1
|
||||||
"collate": {
|
} ],
|
||||||
"query": { <1>
|
"collate": {
|
||||||
"inline" : {
|
"query": { <1>
|
||||||
"match": {
|
"inline" : {
|
||||||
"{{field_name}}" : "{{suggestion}}" <2>
|
"match": {
|
||||||
|
"{{field_name}}" : "{{suggestion}}" <2>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
"params": {"field_name" : "title"}, <3>
|
||||||
"params": {"field_name" : "title"}, <3>
|
"prune": true <4>
|
||||||
"prune": true <4>
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,22 +392,24 @@ accept ordinary analyzer names.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _suggest
|
POST _search
|
||||||
{
|
{
|
||||||
"text" : "obel prize",
|
"suggest": {
|
||||||
"simple_phrase" : {
|
"text" : "obel prize",
|
||||||
"phrase" : {
|
"simple_phrase" : {
|
||||||
"field" : "title.trigram",
|
"phrase" : {
|
||||||
"size" : 1,
|
|
||||||
"direct_generator" : [ {
|
|
||||||
"field" : "title.trigram",
|
"field" : "title.trigram",
|
||||||
"suggest_mode" : "always"
|
"size" : 1,
|
||||||
}, {
|
"direct_generator" : [ {
|
||||||
"field" : "title.reverse",
|
"field" : "title.trigram",
|
||||||
"suggest_mode" : "always",
|
"suggest_mode" : "always"
|
||||||
"pre_filter" : "reverse",
|
}, {
|
||||||
"post_filter" : "reverse"
|
"field" : "title.reverse",
|
||||||
} ]
|
"suggest_mode" : "always",
|
||||||
|
"pre_filter" : "reverse",
|
||||||
|
"post_filter" : "reverse"
|
||||||
|
} ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/search-suggesters.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/search-suggesters.html",
|
||||||
"methods": ["POST", "GET"],
|
"methods": ["POST"],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_suggest",
|
"path": "/_suggest",
|
||||||
"paths": ["/_suggest", "/{index}/_suggest"],
|
"paths": ["/_suggest", "/{index}/_suggest"],
|
||||||
|
@ -13,18 +13,18 @@
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"ignore_unavailable": {
|
"ignore_unavailable": {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
|
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
|
||||||
},
|
},
|
||||||
"allow_no_indices": {
|
"allow_no_indices": {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
|
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
|
||||||
},
|
},
|
||||||
"expand_wildcards": {
|
"expand_wildcards": {
|
||||||
"type" : "enum",
|
"type" : "enum",
|
||||||
"options" : ["open","closed","none","all"],
|
"options" : ["open","closed","none","all"],
|
||||||
"default" : "open",
|
"default" : "open",
|
||||||
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
|
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
|
||||||
},
|
},
|
||||||
"preference": {
|
"preference": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
@ -41,4 +41,4 @@
|
||||||
"required" : true
|
"required" : true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,22 +38,24 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
index: test1
|
index: test1
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: bar.completion
|
completion:
|
||||||
|
field: bar.completion
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
index: test1
|
index: test1
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: baz.completion
|
completion:
|
||||||
|
field: baz.completion
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
@ -291,4 +293,3 @@ setup:
|
||||||
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
|
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
|
||||||
- is_false: _all.total.completion.fields.baz\.completion
|
- is_false: _all.total.completion.fields.baz\.completion
|
||||||
- is_false: _all.total.fielddata.fields
|
- is_false: _all.total.fielddata.fields
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,24 @@ setup:
|
||||||
"Basic tests for suggest API":
|
"Basic tests for suggest API":
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
|
search:
|
||||||
|
body:
|
||||||
|
suggest:
|
||||||
|
test_suggestion:
|
||||||
|
text: "The Amsterdma meetpu"
|
||||||
|
term:
|
||||||
|
field: body
|
||||||
|
|
||||||
|
- match: {suggest.test_suggestion.1.options.0.text: amsterdam}
|
||||||
|
- match: {suggest.test_suggestion.2.options.0.text: meetup}
|
||||||
|
|
||||||
|
---
|
||||||
|
"Suggest API should have deprecation warning":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
suggest:
|
suggest:
|
||||||
body:
|
body:
|
||||||
test_suggestion:
|
test_suggestion:
|
||||||
|
|
|
@ -0,0 +1,314 @@
|
||||||
|
# This test creates one huge mapping in the setup
|
||||||
|
# Every test should use its own field to make sure it works
|
||||||
|
|
||||||
|
setup:
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: test
|
||||||
|
body:
|
||||||
|
mappings:
|
||||||
|
test:
|
||||||
|
"properties":
|
||||||
|
"suggest_1":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_2":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_3":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_4":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_5a":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_5b":
|
||||||
|
"type" : "completion"
|
||||||
|
"suggest_6":
|
||||||
|
"type" : "completion"
|
||||||
|
title:
|
||||||
|
type: keyword
|
||||||
|
|
||||||
|
---
|
||||||
|
"Simple suggestion should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_1: "bar"
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 2
|
||||||
|
body:
|
||||||
|
suggest_1: "baz"
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_1
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 2 }
|
||||||
|
|
||||||
|
---
|
||||||
|
"Simple suggestion array should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_2: ["bar", "foo"]
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "f"
|
||||||
|
completion:
|
||||||
|
field: suggest_2
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 1 }
|
||||||
|
- match: { result.0.options.0.text: "foo" }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_2
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 1 }
|
||||||
|
- match: { result.0.options.0.text: "bar" }
|
||||||
|
|
||||||
|
---
|
||||||
|
"Suggestion entry should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_3:
|
||||||
|
input: "bar"
|
||||||
|
weight: 2
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 2
|
||||||
|
body:
|
||||||
|
suggest_3:
|
||||||
|
input: "baz"
|
||||||
|
weight: 3
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_3
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 2 }
|
||||||
|
- match: { result.0.options.0.text: "baz" }
|
||||||
|
- match: { result.0.options.1.text: "bar" }
|
||||||
|
|
||||||
|
---
|
||||||
|
"Suggestion entry array should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_4:
|
||||||
|
- input: "bar"
|
||||||
|
weight: 3
|
||||||
|
- input: "fo"
|
||||||
|
weight: 3
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 2
|
||||||
|
body:
|
||||||
|
suggest_4:
|
||||||
|
- input: "baz"
|
||||||
|
weight: 2
|
||||||
|
- input: "foo"
|
||||||
|
weight: 1
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_4
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 2 }
|
||||||
|
- match: { result.0.options.0.text: "bar" }
|
||||||
|
- match: { result.0.options.1.text: "baz" }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "f"
|
||||||
|
completion:
|
||||||
|
field: suggest_4
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 2 }
|
||||||
|
- match: { result.0.options.0.text: "fo" }
|
||||||
|
- match: { result.0.options.1.text: "foo" }
|
||||||
|
|
||||||
|
---
|
||||||
|
"Multiple Completion fields should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_5a: "bar"
|
||||||
|
suggest_5b: "baz"
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_5a
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 1 }
|
||||||
|
- match: { result.0.options.0.text: "bar" }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_5b
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 1 }
|
||||||
|
- match: { result.0.options.0.text: "baz" }
|
||||||
|
|
||||||
|
---
|
||||||
|
"Suggestions with source should work":
|
||||||
|
- skip:
|
||||||
|
features: 'warnings'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
suggest_6:
|
||||||
|
input: "bar"
|
||||||
|
weight: 2
|
||||||
|
title: "title_bar"
|
||||||
|
count: 4
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 2
|
||||||
|
body:
|
||||||
|
suggest_6:
|
||||||
|
input: "baz"
|
||||||
|
weight: 3
|
||||||
|
title: "title_baz"
|
||||||
|
count: 3
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
warnings:
|
||||||
|
- "[POST /_suggest] is deprecated! Use [POST /_search] instead."
|
||||||
|
suggest:
|
||||||
|
body:
|
||||||
|
result:
|
||||||
|
text: "b"
|
||||||
|
completion:
|
||||||
|
field: suggest_6
|
||||||
|
|
||||||
|
- length: { result: 1 }
|
||||||
|
- length: { result.0.options: 2 }
|
||||||
|
- match: { result.0.options.0.text: "baz" }
|
||||||
|
- match: { result.0.options.0._index: "test" }
|
||||||
|
- match: { result.0.options.0._type: "test" }
|
||||||
|
- match: { result.0.options.0._source.title: "title_baz" }
|
||||||
|
- match: { result.0.options.0._source.count: 3 }
|
||||||
|
- match: { result.0.options.1.text: "bar" }
|
||||||
|
- match: { result.0.options.1._index: "test" }
|
||||||
|
- match: { result.0.options.1._type: "test" }
|
||||||
|
- match: { result.0.options.1._source.title: "title_bar" }
|
||||||
|
- match: { result.0.options.1._source.count: 4 }
|
|
@ -50,15 +50,16 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_1
|
completion:
|
||||||
|
field: suggest_1
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 2 }
|
- length: { suggest.result.0.options: 2 }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Simple suggestion array should work":
|
"Simple suggestion array should work":
|
||||||
|
@ -75,28 +76,30 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "f"
|
result:
|
||||||
completion:
|
text: "f"
|
||||||
field: suggest_2
|
completion:
|
||||||
|
field: suggest_2
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "foo" }
|
- match: { suggest.result.0.options.0.text: "foo" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_2
|
completion:
|
||||||
|
field: suggest_2
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "bar" }
|
- match: { suggest.result.0.options.0.text: "bar" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Suggestion entry should work":
|
"Suggestion entry should work":
|
||||||
|
@ -125,17 +128,18 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_3
|
completion:
|
||||||
|
field: suggest_3
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 2 }
|
- length: { suggest.result.0.options: 2 }
|
||||||
- match: { result.0.options.0.text: "baz" }
|
- match: { suggest.result.0.options.0.text: "baz" }
|
||||||
- match: { result.0.options.1.text: "bar" }
|
- match: { suggest.result.0.options.1.text: "bar" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Suggestion entry array should work":
|
"Suggestion entry array should work":
|
||||||
|
@ -168,30 +172,32 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_4
|
completion:
|
||||||
|
field: suggest_4
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 2 }
|
- length: { suggest.result.0.options: 2 }
|
||||||
- match: { result.0.options.0.text: "bar" }
|
- match: { suggest.result.0.options.0.text: "bar" }
|
||||||
- match: { result.0.options.1.text: "baz" }
|
- match: { suggest.result.0.options.1.text: "baz" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "f"
|
result:
|
||||||
completion:
|
text: "f"
|
||||||
field: suggest_4
|
completion:
|
||||||
|
field: suggest_4
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 2 }
|
- length: { suggest.result.0.options: 2 }
|
||||||
- match: { result.0.options.0.text: "fo" }
|
- match: { suggest.result.0.options.0.text: "fo" }
|
||||||
- match: { result.0.options.1.text: "foo" }
|
- match: { suggest.result.0.options.1.text: "foo" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Multiple Completion fields should work":
|
"Multiple Completion fields should work":
|
||||||
|
@ -209,28 +215,30 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_5a
|
completion:
|
||||||
|
field: suggest_5a
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "bar" }
|
- match: { suggest.result.0.options.0.text: "bar" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_5b
|
completion:
|
||||||
|
field: suggest_5b
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "baz" }
|
- match: { suggest.result.0.options.0.text: "baz" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Suggestions with source should work":
|
"Suggestions with source should work":
|
||||||
|
@ -263,23 +271,23 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "b"
|
result:
|
||||||
completion:
|
text: "b"
|
||||||
field: suggest_6
|
completion:
|
||||||
|
field: suggest_6
|
||||||
- length: { result: 1 }
|
|
||||||
- length: { result.0.options: 2 }
|
|
||||||
- match: { result.0.options.0.text: "baz" }
|
|
||||||
- match: { result.0.options.0._index: "test" }
|
|
||||||
- match: { result.0.options.0._type: "test" }
|
|
||||||
- match: { result.0.options.0._source.title: "title_baz" }
|
|
||||||
- match: { result.0.options.0._source.count: 3 }
|
|
||||||
- match: { result.0.options.1.text: "bar" }
|
|
||||||
- match: { result.0.options.1._index: "test" }
|
|
||||||
- match: { result.0.options.1._type: "test" }
|
|
||||||
- match: { result.0.options.1._source.title: "title_bar" }
|
|
||||||
- match: { result.0.options.1._source.count: 4 }
|
|
||||||
|
|
||||||
|
- length: { suggest.result: 1 }
|
||||||
|
- length: { suggest.result.0.options: 2 }
|
||||||
|
- match: { suggest.result.0.options.0.text: "baz" }
|
||||||
|
- match: { suggest.result.0.options.0._index: "test" }
|
||||||
|
- match: { suggest.result.0.options.0._type: "test" }
|
||||||
|
- match: { suggest.result.0.options.0._source.title: "title_baz" }
|
||||||
|
- match: { suggest.result.0.options.0._source.count: 3 }
|
||||||
|
- match: { suggest.result.0.options.1.text: "bar" }
|
||||||
|
- match: { suggest.result.0.options.1._index: "test" }
|
||||||
|
- match: { suggest.result.0.options.1._type: "test" }
|
||||||
|
- match: { suggest.result.0.options.1._source.title: "title_bar" }
|
||||||
|
- match: { suggest.result.0.options.1._source.count: 4 }
|
||||||
|
|
|
@ -74,18 +74,19 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "foo"
|
result:
|
||||||
completion:
|
text: "foo"
|
||||||
field: suggest_context
|
completion:
|
||||||
contexts:
|
field: suggest_context
|
||||||
color: "red"
|
contexts:
|
||||||
|
color: "red"
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "foo red" }
|
- match: { suggest.result.0.options.0.text: "foo red" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Category suggest context from path should work":
|
"Category suggest context from path should work":
|
||||||
|
@ -114,45 +115,48 @@ setup:
|
||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "foo"
|
result:
|
||||||
completion:
|
text: "foo"
|
||||||
field: suggest_context_with_path
|
completion:
|
||||||
contexts:
|
field: suggest_context_with_path
|
||||||
color: "red"
|
contexts:
|
||||||
|
color: "red"
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "Foo red" }
|
- match: { suggest.result.0.options.0.text: "Foo red" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "foo"
|
result:
|
||||||
completion:
|
text: "foo"
|
||||||
field: suggest_context_with_path
|
completion:
|
||||||
contexts:
|
field: suggest_context_with_path
|
||||||
color: "blue"
|
contexts:
|
||||||
|
color: "blue"
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "Foo blue" }
|
- match: { suggest.result.0.options.0.text: "Foo blue" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "foo"
|
result:
|
||||||
completion:
|
text: "foo"
|
||||||
field: suggest_context_with_path
|
completion:
|
||||||
contexts:
|
field: suggest_context_with_path
|
||||||
color: ["blue", "red"]
|
contexts:
|
||||||
|
color: ["blue", "red"]
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 2 }
|
- length: { suggest.result.0.options: 2 }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Geo suggest should work":
|
"Geo suggest should work":
|
||||||
|
@ -190,21 +194,22 @@ setup:
|
||||||
indices.get_mapping: {}
|
indices.get_mapping: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
index: test
|
index: test
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "mar"
|
result:
|
||||||
completion:
|
text: "mar"
|
||||||
field: suggest_geo
|
completion:
|
||||||
contexts:
|
field: suggest_geo
|
||||||
location:
|
contexts:
|
||||||
lat : 52.2263
|
location:
|
||||||
lon : 4.543
|
lat : 52.2263
|
||||||
|
lon : 4.543
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "Marriot in Amsterdam" }
|
- match: { suggest.result.0.options.0.text: "Marriot in Amsterdam" }
|
||||||
|
|
||||||
---
|
---
|
||||||
"Multi contexts should work":
|
"Multi contexts should work":
|
||||||
|
@ -240,33 +245,35 @@ setup:
|
||||||
indices.get_mapping: {}
|
indices.get_mapping: {}
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
index: test
|
index: test
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "mar"
|
result:
|
||||||
completion:
|
text: "mar"
|
||||||
field: suggest_multi_contexts
|
completion:
|
||||||
contexts:
|
field: suggest_multi_contexts
|
||||||
location:
|
contexts:
|
||||||
lat : 52.22
|
location:
|
||||||
lon : 4.53
|
lat : 52.22
|
||||||
|
lon : 4.53
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "Marriot in Amsterdam" }
|
- match: { suggest.result.0.options.0.text: "Marriot in Amsterdam" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
suggest:
|
search:
|
||||||
index: test
|
index: test
|
||||||
body:
|
body:
|
||||||
result:
|
suggest:
|
||||||
text: "mar"
|
result:
|
||||||
completion:
|
text: "mar"
|
||||||
field: suggest_multi_contexts
|
completion:
|
||||||
contexts:
|
field: suggest_multi_contexts
|
||||||
color: "blue"
|
contexts:
|
||||||
|
color: "blue"
|
||||||
|
|
||||||
- length: { result: 1 }
|
- length: { suggest.result: 1 }
|
||||||
- length: { result.0.options: 1 }
|
- length: { suggest.result.0.options: 1 }
|
||||||
- match: { result.0.options.0.text: "Marriot in Berlin" }
|
- match: { suggest.result.0.options.0.text: "Marriot in Berlin" }
|
||||||
|
|
Loading…
Reference in New Issue