I am playing around with the completion suggester and I am not getting the scores i expect from it
To reproduce this
-
create the index
PUT mytest
PUT mytest/suggestion/_mapping
{
"suggestion" : {
"_source": {
"enabled": false
},
"_all": {
"enabled": false
},
"properties" : {
"keyword" : {
"type" : "completion",
"analyzer" : "keyword",
"context": {
"category_id": {
"type": "category",
"default": 0
}
}
}
}
}
} -
add 2 documents to the index
PUT mytest/suggestion/1?refresh=true
{
"keyword" : {
"input": "mercedes",
"context": {
"category_id": 91
},
"weight" : 53477373
}
}PUT mytest/suggestion/2?refresh=true
{
"keyword" : {
"input": "mazda",
"context": {
"category_id": 91
},
"weight" : 53477371
}
} -
Query the for the documents
POST mytest/_suggest
{
"autocomplete-suggest" : {
"text" : "m",
"completion" : {
"field" : "keyword",
"context": {
"category_id": 91
}
}
}
}
This will give the following result
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"autocomplete-suggest": [
{
"text": "m",
"offset": 0,
"length": 1,
"options": [
{
"text": "mazda",
"score": 53477372
},
{
"text": "mercedes",
"score": 53477372
}
]
}
]
}
Clearly for mazda the score should be 53477371 and for mercedes the score should be 53477373 but in both cases elastic decides that the score is 53477372
Can somebody explain why this is happening ?
I am using elastic search 1.7.1