seperman / fast-autocomplete

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

Autocomplete not working as expected #28

Open Shivanandroy opened 3 years ago

Shivanandroy commented 3 years ago

Describe the bug Hi, Can you help me understand this behavior?

To Reproduce

from fast_autocomplete import AutoComplete
words = {'xcode': {}, 'xcode version': {}, 'xcode previous version': {}}
autocomplete = AutoComplete(words=words)

and now when I search, I get this result:

autocomplete.search(word='xcode ver', max_cost=1, size=10)

# output: 
[['xcode'], ['xcode version']]

Isn't "xcode version" should be first suggestion?

Expected behavior I was expecting "xcode version" to be the first suggestion.

# output: 
[['xcode version']]

And if that is an expected behavior, how do I get the desired result? Any idea?

seperman commented 3 years ago

@Shivanandroy Sorry I just noticed your question. In the current implementation, when it reaches a word in the graph, the word has a higher score than a word it has not reached yet. Maybe I should modify it so when it gets close to a word in the graph, it puts it up high in the results and removes the previous word from the results.

lazzarello commented 2 years ago

Came across this convention while using this library for a corporate coding quiz interview. I'll take a swing at changing the default behavior.