Hi!
On a lot of websites with completion suggesters the most popular suggestions are at the top. To my understanding this is why if you type 'iPhone' on a webshop the latest iPhone model will show up at the top, and not the one from 5 years ago.
Now I know one can add a higher weight
property to a suggestion when you are PUTing a document, but I know beforehand what is going to be popular so I want to append to the weight
property when a user chooses a suggestion to complete.
I know you can update the weight for a specific option by using scripts (from a very old stackoverflow post, don't know if it works)
POST /products/iphone/1
{
"script" : {
"inline": "ctx._source.suggest.weight += 1"
}
}
But my suggest
field is populated by a copy_to
dynamic mapping as shown below.
Is there any way to create some sort of positive feedback loop for the completed suggestions
PUT test
{
"mappings": {
"properties" : {
"full_text": {
"type": "text",
"store": true
},
"suggest" : {
"type" : "completion"
}
},
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword",
"copy_to": [ "full_text", "suggest" ]
}
}
}
]
}
}
P.S. The idea is explained here too in the 3rd point, but there is no concrete answer