Reputation: 3560
How do I achieve a keyword based autocomplete suggestions in Algolia similar to something like Amazon or Google?
I attempted building the autocomplete based on multiple attributes of an Algolia document, however its purpose does not really help me at completing a phrase but it directs me at selecting a specific product.
Upvotes: 8
Views: 1245
Reputation: 2319
I attempted building the autocomplete based on multiple attributes of an Algolia document, however its purpose does not really help me at completing a phrase but it directs me at selecting a specific product.
If you want to suggest some searches instead of products/objects you can build an index with your searches logs. You can use Algolia's Analytics API + top searches endpoint to get them if you don't have them yet.
You could then store them in a popular_searches
index like that:
{
"value": "my popular search",
"count": 42 // the search frequency
}
And configure:
searchableAttribute
to target the value
attributecustomRanking
to use desc(count)
as the attribute reflecting the popularityThat being said, you should know that such popular searches autocomplete can be super complex to setup to reach the UX of Amazon/Google:
tldr; If you have choice, precompute a list of searches from your products/objects instead of using your query logs :) It will be safer & easier to maintain (I'm pretty sure that's what Amazon do).
Upvotes: 7
Reputation: 716
I have not used algolia but google returns https://www.algolia.com/doc/search/auto-complete#introduction
Upvotes: -2