Goal: When the user types a query in selectize
input, I'd like to filter the drop-down based on the usual string matching but also based on a custom similarity metric. For instance, if the user types 'Obama', I'd like the suggestions to contain 'Barack Obama', 'Obamacare', etc. (string matching) but also 'president' or 'politician' (synonyms).
Setting: the list of synonyms is returned in real-time by some function in server.R
that takes what the user has typed as input. I think I need to use the 'Server-side selectize' approach described in this tutorial: https://shiny.rstudio.com/articles/selectize.html:
The client-side selectize input relies solely on JavaScript to process searching on typing. The server-side selectize input uses R to process searching, and R will return the filtered data to selectize. To use the server version, you need to create a selectize instance in the UI, and update it to the server version
Problem:
- how can I access the character string as it is being typed by the user in the text box to feed my function?
- how can I get the
updateSelectizeInput
function to take the list of synonyms returned by my function into account?