Reputation: 41785
I got the completion suggest working for autocomplete
However I have a question that I can't answer myself
Why are we storing the suggest in a field of the document?
GET /my_index/_search
{
hits: [{
"_id": 1,
"suggest": {
"input": [
"p1",
"p22",
],
"weight": 1
}
}, {
"_id": 2,
"suggest": {
"input": [
"p22",
"p3",
],
"weight": 1
}
}]
}
For autocomplete
, don't we just need a list of phrases?
[
"p1",
"p22",
"p3"
]
suggest
and the doc
?suggest
input , p22
in the example. When I ask for autocomplete
for p2
I get two p22
.
is there a way of handling this?Upvotes: 0
Views: 93
Reputation: 217594
There's no other way to store suggestions than storing them in a completion
field inside the document itself. This gives you maximum flexibility, because even if two documents have the same or similar suggestions, you can give one a higher weight than the other if you deem necessary.
If you have multiple documents with the same suggestions, you can leverage the skip_duplicates
setting and ES will filter out duplicate suggestions from the response.
Upvotes: 1