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

Extension to phrases with variables #17

Open
ksmithra opened this issue Nov 7, 2020 · 1 comment
Open

Extension to phrases with variables #17

ksmithra opened this issue Nov 7, 2020 · 1 comment

Comments

@ksmithra
Copy link

ksmithra commented Nov 7, 2020

Thanks for the wonderful package.
I am exploring if this package can be extended to support typeahead where the phrases can have variables in them. Enumeration all possible values for those variables may be ruled out. For example consider below phrases:
host {host_name} is from {location_name}
hello {host_name}
etc.
wherein the values for {host_name} and {location_name} would come from an external lookup database.
Is it possible to achieve this with the data structure used in the package?
Thanks much for any help.

@seperman
Copy link
Owner

Hi @ksmithra
There are some pieces of the original package that I never open sourced and would make it easier to achieve what you are describing. If you checkout https://fair.com where this package is used for the autocomplete you can see some example. For example type bmw in santa or bmw in santa monica and see the autocomplete results. The homepage doesn't show all the results from autocomplete but if you click search and go to a page like https://www.fair.com/cars/used/bmw-in-santa-monica you can see up to 5 results from autocomplete when typing.

Now getting back to how you can use this package to do what you want, you can add words like this:

  • host foo
  • host bar
  • is from los angeles
  • is from paris

Then when typing host you should get host foo and host bar in the results.
once you type host foo is from it should five you both host foo is from los angeles and host foo is from paris

You can see an example video of how this can be translated to something like Lucene query language to return search results from Elasticsearch here:
https://zepworks.com/posts/you-autocomplete-me/#demo-2

Note that the part that converts the results into Lucene query is not open sourced.

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