0

I'm looking to return the number of results found in an ajax fashion on Algolia instant search.

A little field saying something like "There are X number of results" and refines as the characters are typed.

I've read you utilise 'nbHits' but i'm unsure of how to go about it.. Being from a design background.

Thanks for help in advance.

John Macpherson
  • 167
  • 1
  • 5

2 Answers2

1

The instantsearch.js stats widget shows the number of results and speed of the search. If you don't want to use the widget, I believe you can still use {{nbHits}} inside of your template wherever you want the number to print.

Josh Dzielak
  • 1,803
  • 17
  • 19
1

Very easy when you know how, Thanks for pointing me in the right direction Josh.

This works:

search.addWidget(
    instantsearch.widgets.stats({
        container: '.no-of-results'
    })
);
John Macpherson
  • 167
  • 1
  • 5