elasticsearch/elasticsearch — pull request #3528 by mattweber (2013-08-18 04:11:06+00:00)
Title: Add score_mode to CompletionSuggester

Support various score_modes in the CompletionSuggester. Modes supported are max, min, total, and product. This is useful when you have multiple suggestions with the same output but different inputs and weights.

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

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

curl -X POST 'localhost:9200/music/_suggest?pretty' -d '{
"song-suggest" : {
"text" : "n",
"completion" : {
"field" : "suggest",
"score_mode": "total"
}
}
}'
{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"song-suggest" : [ {
"text" : "n",
"offset" : 0,
"length" : 4,
"options" : [ {
"text" : "Nirvana - Nevermind",
"score" : 5.0, "payload" : {"artistId":2321}
} ]
} ]
}

```

Not sure this is the best approach but I wanted to put it out there for comments.