Question

Is it possible to implement autocomplete functionality on any of the haystack views (link here) without the need of creating your custom one? If so, how would be an example?

Was it helpful?

Solution

To make it effective, autocomplete has to operate on n-gram fields (EdgeNgramField and NgramField). Since it doesn't make much sense to do faceting on n-gram fields, as the documentation says, it also wouldn't make sense to implement autocomplete on FacetedSearhView. But besides that, since you're not going to render any result page in your autocomplete view, it's hard to see what would you gain with using Haystack's view instead of just writing your own view. You'll have to return the data serialized in JSON or some other format anyway, so it seems to me you wouldn't gain much with subclassing SearchView or modifying basic_search.

The example autocomplete view in the documentation gives you a fully working starting point. If you don't need to do some heavier processing of results or the query, you don't need anything more complex.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top