App Search + AutoComplete

We just signed up for the App Search Pro plan and have a process in place to load our engines via the API calls. It is working great. My question is how do we implement AutoComplete (typeahead sentence completion) with App Search? Getting a front end AutoComplete tied into our site isnt a huge deal - there are lots of jQuery examples out there. But we are having difficulty getting CONTENT for it. We dont want to do just a regular API search call, because that isnt what we are looking for. For example, when searching for computer electronics if I type “US” I would expect the typeahead/autocomplete to suggest the following options “USB mouse”, “USB keyboard”, “USB optical drive”, etc… I dont know how we would get those suggestions. We would not want to call the API search because all that is going to do is do a search on “US” and return X number of documents that match that.

Has anyone here on the App Search plan implemented AutoComplete / typeahead for their site?

@jrhoads

There is no explicit way to just get prefix matches for an autosuggest.

However, it should be possible with the search endpoint to get the behavior you’re looking for. You could try either iterating through the results and looking for the first prefix match to use as the type ahead “hint”, or optionally, you could sort the results client side so that prefix matches are ordered before non-prefix matches.

I took the latter approach, using an engine of node modules, and was able to get reasonable results:

latest

Hope that helps!