Has anyone created or seen a Shiny app featuring search box widget giving contextual suggestions as you type, based on fuzzy matching?
Bloomberg terminal uses it, Google uses it. One of the possible underlying technologies is called elasticsearch.org
's fuzzy query, with two R implementations:
duncantl/RElasticSearch
ropensci/elastic
Search box filter coming with the basic Shiny
's datatable doesn't quite cut it.
If this is something yet to be integrated with Shiny, any rough guide how to build it? I suspect it would be extremely useful on biggish tables (or documents) with lots of text, when you want to look for specific rows, without displaying the full table.
Maybe a combobox could be fed a list from stringdist() that would compare the input string against a known list and provide the items with the 10 items with the shortest string distance. Would probably be very inefficient with huge lists, but the algorithm is fairly fast when comparing against a short list.
One of the stringdist methods even compares based on how words are pronounced, not sure if that's useful.
If you are using selectInput(), then you can set the parameter "choices" to a vector, and the contents of that vector will appear as the user types. The problem with this is that the user cannot select anything that is not contained in the vector.
UI:
selectInput(
"reference_name", label = h3("Selection"), choices = vector_of_search_possibilities, selectize = TRUE, selected = "Alabama"
)
SERVER: reference this object using
input$reference_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With