widgets stats

Edit this page

Description

The stats widget is used to display useful insights about the current results.

By default, it will display the number of hits and the time taken to compute the results inside the engine.

Live example

You can find an example at the end of the page or a live example in our widget showcase.

Usage

Usage
const search = instantsearch( /* parameters */ );

const widget = instantsearch.widgets.stats({ container: string|HTMLElement, templates: [StatsWidgetTemplates], cssClasses: [StatsWidgetCssClasses], }: StatsWidgetOptions);
search.addWidget(widget);

Options

StatsWidgetOptions

StatsWidgetTemplates

  • text[string|function]

    Text template, provided with hasManyResults, hasNoResults, hasOneResult, hitsPerPage, nbHits, nbPages, page, processingTimeMS, query.

StatsWidgetCssClasses

  • root[string|Array<string>]

    CSS class to add to the root element.

  • text[string|Array<string>]

    CSS class to add to the text span element.

Widget

  • render[function]

    Called after each search response has been received

  • getConfiguration[function]

    Let the widget update the configuration of the search with new parameters

  • init[function]

    Called once before the first search

Example

search.addWidget(
  instantsearch.widgets.stats({
    container: '#stats-container'
  })
);

Can't find what you are looking for? Open an issue, we'll get back to you.