Combobox filteringmode fuzzy

when typing in the combobox, I want to filter the items available by means of a fuzzy filtering mechanism.

Example:
items: [Jacques, Dorothée, Rose-Mary]

typed in: Dorotee //no accent, and missing h

combobox should nonetheless retain “Dorothée” as the closest match.

I was thinking about using the Levenshtein distance to measure the similarity between the typed value and the items in the Combobox, but I am in doubt how and where to implement this.

Suggestions are greatly appreciated!

Hi,

You might want to try the
LuceneContainer
add-on. There’s a FuzzyQuery available in Lucene, which might be able to do what you need. For some reason the LuceneContainer class does not implement Container.Filterable interface, but instead has search methods of its own. This might be something you need to change in order to make it work with ComboBox.

The ComboBox component (client side widget) does not really work with non-exact matches so a TextField with a TextChangeListener and a separate popup view would probably work better in your case. Not trivial to get the positioning of the popup right and keyboard actions to work nicely, but I know it has been done by some and there should even be at least partial sample code somewhere on the forum (maybe Google can help).

If you are not afraid to do some client side development, you could probably borrow from the
PopupButton
and
SearchField
add-ons, or perhaps even use the latter as is. It might not be up-to-date for the latest Vaadin versions, though (SuperImmediateTextField is an old add-on, now the equivalent functionality can be achieved using a TextChangeListener) - if so,
writing in the forum thread about it
might help.