Fuzzy autocomplete score

Hello. Im working with mongodb atlas search and trying to implement fuzzy autocomplete search. But I noticed that fuzzy autocomplete gives a default 1 score for all matches. For example, apple with score 1 and applu with score 1 input strings for field value “apple”. Is it possible to achieve that there is a better result for a clear match that for a fuzzy one?

Hi @Andrey_Golub,
if I understand you correctly, you have a field with value ‘apple’ in a document, and you tried two autocomplete queries, one with the query ‘apple’ and the other with ‘applu’. If that’s the case, it seems like a normal behaviour: the score applies to the returned documents, not the query. The document with value ‘apple’ will have a score of 1 because it’s probably the only result returned, for whichever query entering the scope of your maxEdits setting.
If it’s the other way around, you have two documents with a different field value, one with ‘apple’ and the other with ‘applu’, and your query is ‘apple’. Your query should then definitely return a highest score for the document with the value ‘apple’. In this case, you should post here your search index and your query. Check if the score field in your autocomplete query syntax hasn’t a constant set. Also, bear in mind that a text operator would give you an higher fidelity in score than autocomplete .

I have simple collection with 2 documents: {"_id": “…”, “wordValue”: “Apple”}, {"_id":"…", “wordValue”: “Apply”}

I created search index:

“mappings”: {
“dynamic”: true,
“fields”: {
“wordValue”: [
“foldDiacritics”: false,
“maxGrams”: 256,
“minGrams”: 2,
“tokenization”: “edgeGram”,
“type”: “autocomplete”

And when i execute the query

[{ “$search” : { “autocomplete” : { “path” : “wordValue”, “query” : “apple”, “fuzzy” : { “prefixLength” : 1, “maxEdits” : 1, “maxExpansions” : 256 } } } }, { “$project” : { “_id” : 0, “wordValue” : 1, “score” : { “$meta” : “searchScore” } } }]

I get score values 1 and 1.
But it seems logical to me that the score value for a document with a value “Apple” should be greater than for document with value “Apply”. Is it possible to make the score values different in this case? Or am I doing something wrong?

You are right. I can’t find much in the documentation, only that ‘autocomplete offers less fidelity in score in exchange for faster query execution’. Autocomplete just doesn’t seem to be designed to score the complete query; it just gives a score of 1 for every document still competing for a good match.
I think you have to stick with a string index and a text query with fuzzy search enabled to have a meaningful score to work with.