What doest the weight means in completion suggester?


(Litaotao) #1

what does the 'weight' means ?
what if leave out the 'weight' data ?

curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{
    "name" : "Nevermind",
    "suggest" : {
        "input": [ "Nevermind", "Nirvana" ],
        "output": "Nirvana - Nevermind",
        "payload" : { "artistId" : 2321 },
        "weight" : 34
    }
}'

how does the score calculated in the bellow request response ?

curl -X POST 'localhost:9200/music/_suggest?pretty' -d '{
    "song-suggest" : {
        "text" : "n",
        "completion" : {
            "field" : "suggest"
        }
    }
}'

{
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "song-suggest" : [ {
    "text" : "n",
    "offset" : 0,
    "length" : 1,
    "options" : [ {
      "text" : "Nirvana - Nevermind",
      "score" : 34.0, "payload" : {"artistId":2321}
    } ]
  } ]
}

(Isabel Drost-Fromm) #2

Weight influences your scoring. For more details see here:

and here:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html

According to https://www.elastic.co/blog/you-complete-me

Note: If you don't specify a weight then Elasticsearch will use the 
term frequency of the search phrase within its segment, usually 1.
This is pretty much meaningless as far as suggestions go. It is 
better to control order using weight.

According to https://www.elastic.co/blog/you-complete-me

As you can imagine, the results are now sorted by weight,
which is returned as the score:

Hope this helps,
Isabel


(Litaotao) #3

@mainec hi, mainec, thanks a lot for the immediately reply, that's very helpful. great thanks again.


(system) #4