I am looking to implement a feature for "conditional autocompleting" based on the text input in the query. For instance:
A user could:
Type "f", and receive suggestions for field names like "field_name" and "field_age".
If the user then types or selects "field_name" followed by "=", there would be a request for a specific list of data unique to "field_name" such as [Albert, Bob, Clarisse].
When the user enters a space, options like ["AND", "OR", "==", "!="] would be fetched remotely. If the user chooses "==" then based on the current string, say "field_name == ' ' ", the list [Albert, Bob, Clarisse] would be used.
Alternatively, if the user types field_age... then a request would be made specifically for a list or json object containing ages [7,3,6]. An example input in a search box might look like:
field_name = 'Albert' AND field_age = '7'
I have explored typeahead.js, but it seems to fetch all the data for autocompletion rather than "data as needed" (such as names and ages). Since names can be extensive, I wish to avoid downloading all values for every possible field, which could result in a large download.
What is the most effective way to achieve this? Does typeahead.js support this, or is there a better alternative library?