jeancroy / FuzzySearch

:mag: Fast autocomplete suggestion engine using approximate string matching
MIT License
194 stars 32 forks source link

hiding html comments #34

Closed halukkaramete closed 2 years ago

halukkaramete commented 2 years ago

Is it possible to let fuzzy-search search items like

United States <!--America-->

so the user can type America and match it but only see this in the search results:

United States

This way, we can add lots of helper keys or synonyms in HTML comments to help the search but not confuse the user with those helper words..

Think of it like this

user types "below" and you match "under" because of this: under <!--below underneath -->

or user types "heaven" or "gardens of eden" and you match "paradise" because of this: paradise <!--heaven, gardens of eden -->]

etc..

jeancroy commented 2 years ago

The way I recommend to format entries as:

Entry: {
     Name:"United States",
     Synonym:["US","USA","America"],
     DisplayHtml: "--code here--"
}

Then you index both name and synomyn. (Do not index html) Then the html is reserved for display.

jeancroy commented 2 years ago

You can look at keys and output_map options to help you in this.

https://github.com/jeancroy/FuzzySearch#collect-information-and-normalize

https://github.com/jeancroy/FuzzySearch#get-a-field-from-the-original-object