Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions docs/reference/search/suggesters/completion-suggest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ POST music/_search?pretty
{
"suggest": {
"song-suggest" : {
"prefix" : "nir",
"completion" : {
"field" : "suggest"
"prefix" : "nir", <1>
"completion" : { <2>
"field" : "suggest" <3>
}
}
}
Expand All @@ -167,6 +167,10 @@ POST music/_search?pretty
// CONSOLE
// TEST[continued]

<1> Prefix used to search for suggestions
<2> Type of suggestions
<3> Name of the field to search for suggestions in

returns this response:

[source,js]
Expand Down Expand Up @@ -218,14 +222,15 @@ filtering but using suggest on the `_search` endpoint does:

[source,js]
--------------------------------------------------
POST music/_search?size=0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why this is confusing, but it's also an interesting piece of information that this size refers to the number of search hits to return. Maybe leave this and extend <3> to briefly explain the difference and why size=0 makes sense here as the url parameter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Christoph and I talked about this and it seems like Elasticsearch is already optimized when suggest only search requests are executed (see QueryPhase.execute(SearchContext searchContext)), so it seems like adding the size=0 does not really make sense.

POST music/_search
{
"_source": "suggest",
"_source": "suggest", <1>
"suggest": {
"song-suggest" : {
"prefix" : "nir",
"completion" : {
"field" : "suggest"
"field" : "suggest", <2>
"size" : 5 <3>
}
}
}
Expand All @@ -234,6 +239,10 @@ POST music/_search?size=0
// CONSOLE
// TEST[continued]

<1> Filter the source to return only the `suggest` field
<2> Name of the field to search for suggestions in
<3> Number of suggestions to return

Which should look like:

[source,js]
Expand Down