Shopify: How to have auto-complete show Most Popular?

We are seeing search results with the Most Popular relevance. However, we are not seeing the same results listed with auto-complete. How do we get auto-complete to show results based on the Most Popular relevance?

Hi @roger1

Did you check the popularIn source parameter for autocomplete.js ?

I’ve never used it but it seems that it could do what you want !

Cheers :wink:

HI @pierre.aurele.martin,

Thanks for the suggestion. We’ll look into it!


Thanks @pierre.aurele.martin for suggesting something again on a Shopify related question, it was definitely not a bad guess! If you’d like to get access to a test store, I’d be happy to grant you access to one, so that you can see how it works!

In this case, “Most popular” is a specific replica that you can setup in the app.
The goal here is to target a specific replica using the autocomplete.
To be honest, I would actually not suggest that @roger1.
Relevance is really the main index that your users should use. Indeed, for the others, this forces the sort order before the textual relevance, which makes a result with a lot of typos but ordered more placed before one that had a perfect textual match.

If you want to try it anyway, you’re free to do this.
For the autocomplete, put this replica’s index name in algolia_autocomplete.js.
This name can be found it in the URL after switching the sort order, just don’t forget to remove the index prefix (usually shopify_).

var autocomplete = {
  // ...
  products: {
    enabled: algolia.config.index_products,
    hitsPerPage: algolia.config.products_autocomplete_hits_per_page,
    index: index('products_recently_ordered_count_desc'), // was index('products'),
    templates: {
      empty: algolia.compileTemplate('autocomplete_products_empty'),
      footer: algolia.compileTemplate('autocomplete_footer'),
      hit: algolia.compileTemplate('autocomplete_product')
  // ...