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) {
|
||||
super(settings);
|
||||
this.searchRequestParsers = searchRequestParsers;
|
||||
controller.registerHandler(POST, "/_suggest", this);
|
||||
controller.registerHandler(GET, "/_suggest", this);
|
||||
controller.registerHandler(POST, "/{index}/_suggest", this);
|
||||
controller.registerHandler(GET, "/{index}/_suggest", this);
|
||||
controller.registerAsDeprecatedHandler(POST, "/_suggest", this,
|
||||
"[POST /_suggest] is deprecated! Use [POST /_search] instead.", deprecationLogger);
|
||||
controller.registerAsDeprecatedHandler(GET, "/_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
|
||||
|
|
|
@ -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
|
||||
development.
|
||||
|
||||
The suggest request part is either defined alongside the query part in a
|
||||
`_search` request or via the REST `_suggest` endpoint.
|
||||
The suggest request part is defined alongside the query part in a `_search`
|
||||
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]
|
||||
--------------------------------------------------
|
||||
|
@ -30,25 +34,6 @@ POST twitter/_search
|
|||
// CONSOLE
|
||||
// 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
|
||||
identified with an arbitrary name. In the example below two suggestions
|
||||
are requested. Both `my-suggest-1` and `my-suggest-2` suggestions use
|
||||
|
@ -56,8 +41,9 @@ the `term` suggester, but have a different `text`.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST _suggest
|
||||
POST _search
|
||||
{
|
||||
"suggest": {
|
||||
"my-suggest-1" : {
|
||||
"text" : "tring out Elasticsearch",
|
||||
"term" : {
|
||||
|
@ -71,6 +57,7 @@ POST _suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:twitter]
|
||||
|
@ -85,6 +72,10 @@ in the suggest text and if found an arbitrary number of options.
|
|||
--------------------------------------------------
|
||||
{
|
||||
"_shards": ...
|
||||
"hits": ...
|
||||
"took": 2,
|
||||
"timed_out": false,
|
||||
"suggest": {
|
||||
"my-suggest-1": [ {
|
||||
"text": "tring",
|
||||
"offset": 0,
|
||||
|
@ -103,9 +94,12 @@ in the suggest text and if found an arbitrary number of options.
|
|||
} ],
|
||||
"my-suggest-2": ...
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// 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
|
||||
|
@ -123,8 +117,9 @@ and applies to the `my-suggest-1` and `my-suggest-2` suggestions.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST _suggest
|
||||
POST _search
|
||||
{
|
||||
"suggest": {
|
||||
"text" : "tring out Elasticsearch",
|
||||
"my-suggest-1" : {
|
||||
"term" : {
|
||||
|
@ -137,6 +132,7 @@ POST _suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
|
|
|
@ -152,8 +152,9 @@ documents once deleted are never shown. This request:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST music/_suggest?pretty
|
||||
POST music/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"song-suggest" : {
|
||||
"prefix" : "nir",
|
||||
"completion" : {
|
||||
|
@ -161,6 +162,7 @@ POST music/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
@ -175,6 +177,10 @@ returns this response:
|
|||
"successful" : 5,
|
||||
"failed" : 0
|
||||
},
|
||||
"hits": ...
|
||||
"took": 2,
|
||||
"timed_out": false,
|
||||
"suggest": {
|
||||
"song-suggest" : [ {
|
||||
"text" : "nir",
|
||||
"offset" : 0,
|
||||
|
@ -191,8 +197,10 @@ returns this response:
|
|||
} ]
|
||||
} ]
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// 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
|
||||
|
@ -289,8 +297,9 @@ you can have a typo in your search and still get results back.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST music/_suggest?pretty
|
||||
POST music/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"song-suggest" : {
|
||||
"prefix" : "nor",
|
||||
"completion" : {
|
||||
|
@ -301,6 +310,7 @@ POST music/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
|
@ -346,8 +356,9 @@ you can express a prefix as a regular expression
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST music/_suggest?pretty
|
||||
POST music/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"song-suggest" : {
|
||||
"regex" : "n[ever|i]r",
|
||||
"completion" : {
|
||||
|
@ -355,6 +366,7 @@ POST music/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
|
|
|
@ -138,9 +138,10 @@ filters suggestions by multiple categories:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST place/_suggest?pretty
|
||||
POST place/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"place_suggestion" : {
|
||||
"prefix" : "tim",
|
||||
"completion" : {
|
||||
"field" : "suggest",
|
||||
|
@ -151,6 +152,7 @@ POST place/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
@ -165,9 +167,10 @@ suggestions associated with some categories:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST place/_suggest?pretty
|
||||
POST place/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"place_suggestion" : {
|
||||
"prefix" : "tim",
|
||||
"completion" : {
|
||||
"field" : "suggest",
|
||||
|
@ -181,6 +184,7 @@ POST place/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
@ -275,9 +279,10 @@ the encoded geohash of a geo point:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST place/_suggest
|
||||
POST place/_search
|
||||
{
|
||||
"suggest": {
|
||||
"place_suggestion" : {
|
||||
"prefix" : "tim",
|
||||
"completion" : {
|
||||
"field" : "suggest",
|
||||
|
@ -291,6 +296,7 @@ POST place/_suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
@ -303,9 +309,10 @@ than others, as shown by the following:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST place/_suggest?pretty
|
||||
POST place/_search?pretty
|
||||
{
|
||||
"suggest": {
|
||||
"place_suggestion" : {
|
||||
"prefix" : "tim",
|
||||
"completion" : {
|
||||
"field" : "suggest",
|
||||
|
@ -329,6 +336,7 @@ POST place/_suggest?pretty
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
|
|
@ -84,8 +84,9 @@ suggester in the same spot you'd use the `term` suggester:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST _suggest
|
||||
POST test/_search
|
||||
{
|
||||
"suggest": {
|
||||
"text": "noble prize",
|
||||
"simple_phrase": {
|
||||
"phrase": {
|
||||
|
@ -103,6 +104,7 @@ POST _suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
|
@ -112,6 +114,10 @@ The response contains suggestions scored by the most likely spell correction fir
|
|||
--------------------------------------------------
|
||||
{
|
||||
"_shards": ...
|
||||
"hits": ...
|
||||
"timed_out": false,
|
||||
"took": 3,
|
||||
"suggest": {
|
||||
"simple_phrase" : [
|
||||
{
|
||||
"text" : "noble prize",
|
||||
|
@ -125,8 +131,11 @@ The response contains suggestions scored by the most likely spell correction fir
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/"_shards": .../"_shards": "$body._shards",/]
|
||||
// TESTRESPONSE[s/"hits": .../"hits": "$body.hits",/]
|
||||
// TESTRESPONSE[s/"took": 3,/"took": "$body.took",/]
|
||||
|
||||
==== Basic Phrase suggest API parameters
|
||||
|
||||
|
@ -217,8 +226,9 @@ The response contains suggestions scored by the most likely spell correction fir
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST _suggest
|
||||
POST _search
|
||||
{
|
||||
"suggest": {
|
||||
"text" : "noble prize",
|
||||
"simple_phrase" : {
|
||||
"phrase" : {
|
||||
|
@ -243,6 +253,7 @@ POST _suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
<1> This query will be run once for every suggestion.
|
||||
|
@ -381,8 +392,9 @@ accept ordinary analyzer names.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST _suggest
|
||||
POST _search
|
||||
{
|
||||
"suggest": {
|
||||
"text" : "obel prize",
|
||||
"simple_phrase" : {
|
||||
"phrase" : {
|
||||
|
@ -400,6 +412,7 @@ POST _suggest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"suggest": {
|
||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/search-suggesters.html",
|
||||
"methods": ["POST", "GET"],
|
||||
"methods": ["POST"],
|
||||
"url": {
|
||||
"path": "/_suggest",
|
||||
"paths": ["/_suggest", "/{index}/_suggest"],
|
||||
|
|
|
@ -38,18 +38,20 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
index: test1
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
field: bar.completion
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
index: test1
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
|
@ -291,4 +293,3 @@ setup:
|
|||
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
|
||||
- is_false: _all.total.completion.fields.baz\.completion
|
||||
- is_false: _all.total.fielddata.fields
|
||||
|
||||
|
|
|
@ -13,6 +13,24 @@ setup:
|
|||
"Basic tests for suggest API":
|
||||
|
||||
- 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:
|
||||
body:
|
||||
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: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
field: suggest_1
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 2 }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 2 }
|
||||
|
||||
---
|
||||
"Simple suggestion array should work":
|
||||
|
@ -75,28 +76,30 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "f"
|
||||
completion:
|
||||
field: suggest_2
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "foo" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "foo" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
field: suggest_2
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "bar" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "bar" }
|
||||
|
||||
---
|
||||
"Suggestion entry should work":
|
||||
|
@ -125,17 +128,18 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
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" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 2 }
|
||||
- match: { suggest.result.0.options.0.text: "baz" }
|
||||
- match: { suggest.result.0.options.1.text: "bar" }
|
||||
|
||||
---
|
||||
"Suggestion entry array should work":
|
||||
|
@ -168,30 +172,32 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
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" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 2 }
|
||||
- match: { suggest.result.0.options.0.text: "bar" }
|
||||
- match: { suggest.result.0.options.1.text: "baz" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
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" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 2 }
|
||||
- match: { suggest.result.0.options.0.text: "fo" }
|
||||
- match: { suggest.result.0.options.1.text: "foo" }
|
||||
|
||||
---
|
||||
"Multiple Completion fields should work":
|
||||
|
@ -209,28 +215,30 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
field: suggest_5a
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "bar" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "bar" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "b"
|
||||
completion:
|
||||
field: suggest_5b
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "baz" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "baz" }
|
||||
|
||||
---
|
||||
"Suggestions with source should work":
|
||||
|
@ -263,23 +271,23 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
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 }
|
||||
|
||||
- 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,8 +74,9 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "foo"
|
||||
completion:
|
||||
|
@ -83,9 +84,9 @@ setup:
|
|||
contexts:
|
||||
color: "red"
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "foo red" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "foo red" }
|
||||
|
||||
---
|
||||
"Category suggest context from path should work":
|
||||
|
@ -114,8 +115,9 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "foo"
|
||||
completion:
|
||||
|
@ -123,13 +125,14 @@ setup:
|
|||
contexts:
|
||||
color: "red"
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "Foo red" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "Foo red" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "foo"
|
||||
completion:
|
||||
|
@ -137,13 +140,14 @@ setup:
|
|||
contexts:
|
||||
color: "blue"
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "Foo blue" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "Foo blue" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "foo"
|
||||
completion:
|
||||
|
@ -151,8 +155,8 @@ setup:
|
|||
contexts:
|
||||
color: ["blue", "red"]
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 2 }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 2 }
|
||||
|
||||
---
|
||||
"Geo suggest should work":
|
||||
|
@ -190,9 +194,10 @@ setup:
|
|||
indices.get_mapping: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
index: test
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "mar"
|
||||
completion:
|
||||
|
@ -202,9 +207,9 @@ setup:
|
|||
lat : 52.2263
|
||||
lon : 4.543
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "Marriot in Amsterdam" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "Marriot in Amsterdam" }
|
||||
|
||||
---
|
||||
"Multi contexts should work":
|
||||
|
@ -240,9 +245,10 @@ setup:
|
|||
indices.get_mapping: {}
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
index: test
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "mar"
|
||||
completion:
|
||||
|
@ -252,14 +258,15 @@ setup:
|
|||
lat : 52.22
|
||||
lon : 4.53
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "Marriot in Amsterdam" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "Marriot in Amsterdam" }
|
||||
|
||||
- do:
|
||||
suggest:
|
||||
search:
|
||||
index: test
|
||||
body:
|
||||
suggest:
|
||||
result:
|
||||
text: "mar"
|
||||
completion:
|
||||
|
@ -267,6 +274,6 @@ setup:
|
|||
contexts:
|
||||
color: "blue"
|
||||
|
||||
- length: { result: 1 }
|
||||
- length: { result.0.options: 1 }
|
||||
- match: { result.0.options.0.text: "Marriot in Berlin" }
|
||||
- length: { suggest.result: 1 }
|
||||
- length: { suggest.result.0.options: 1 }
|
||||
- match: { suggest.result.0.options.0.text: "Marriot in Berlin" }
|
||||
|
|
Loading…
Reference in New Issue