Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable partial matching when user types final words of entity without initial ones? #26

Open
AndreaSottana opened this issue Jun 23, 2021 · 2 comments

Comments

@AndreaSottana
Copy link

AndreaSottana commented Jun 23, 2021

One of the feature of the repository, as mentioned in the README, is that

Elasticsearch's Autocomplete suggestor does not handle any sort of combination of the words you have put in. For example Fast Autocomplete can handle 2018 Toyota Camry in Los Angeles when the words 2018, Toyota Camry, Los Angeles are seperately fed into it. While Elasticsearch's autocomplete needs that whole sentence to be fed to it to show it in Autocomplete results.

However, I would like to know if there is an easy way to achieve the opposite, i.e. if an "entity" (let's call it a word in the context of this repository, even though it's technically made up by multiple words) is searched by typing only the final words that make up this entity, how do we get autocomplete to retrieve it correctly?

As an example, let's take this

from fast_autocomplete import AutoComplete
words = {'anti money laundering': {}, 'notification letter': {}, 'lending institution': {}}
autocomplete = AutoComplete(words=words)
print(autocomplete.search(word='laundering'))

this would return an empty list []. Is there a way to enable recognition of "anti money laundering" as a single item when the user only types the final word "laundering"? Likewise, if I do

print(autocomplete.search(word='le'))

I would want to see [['notification letter'], ['lending institution']] as results instead of just "lending institution". Not sure if this feature exists, if so, could you explain how to enable it? If it doesn't exist, have you ever considered adding it as a feature?

@seperman
Copy link
Owner

Hi @AndreaSottana
These are some features that I have not got the permissions to opensource yet. The easiest thing to do is to also feed those individual words to fast_autocomplete. So something like this:

words = {'anti money laundering': {'label': 'anti money laundering'}, 'notification letter': {'label': ''notification letter'}, 'laundering': {'label': 'anti money laundering'}}

By doing so once fast_autocomplete returns the results, you use the labels to show the final results to the user. You will probably end up having some logic after that to maybe show more options. Maybe label is a list of items and you use some other algorithm to decide which one of those to show to the user.

@AndreaSottana
Copy link
Author

Thanks @seperman
will do as you suggest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants