What doest the weight means in completion suggester?

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}
    } ]
  } ]
}

Weight influences your scoring. For more details see here:

and here:

According to You Complete Me | Elastic Blog

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 You Complete Me | Elastic Blog

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

Hope this helps,
Isabel

1 Like

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