seperman / fast-autocomplete

Fast Autocomplete: When Elastcsearch suggestions are not fast and flexible enough
MIT License
267 stars 40 forks source link

Synonyms overwrite main words which are identical but with different meanings #29

Closed AndreaSottana closed 2 years ago

AndreaSottana commented 3 years ago

Hello, I've noticed that when a synonym is the same as an item in the words, the item in the words will not feature in the search suggestions as it seems to somehow be overwritten by the synonym. For example, if we take the word "letters" which can mean either the letters of the alphabet, or the parcels, we could have a situation like the following below:

from fast_autocomplete import AutoComplete

words = {'letters': {}, 'numbers': {}, 'parcels': {}}
synonyms = {'parcels': ['letters']}
autocomplete = AutoComplete(words=words, synonyms=synonyms)
print(autocomplete.search(word='let'))

This only returns [['parcels']]

whereas I would expect the following to be returned [['parcels'], ['letters']]

Is this a bug? If not, how can I get the correct behaviour?

seperman commented 2 years ago

Hi @AndreaSottana Yes it is a bug. I will take a look at it.

seperman commented 2 years ago

Actually I take it back. In the current implementation, words can only have one meaning. As you can see here the the parcel leads to only one word in the graph: Screenshot from 2021-10-12 11-02-53