The Stats connector provides the logic to build a custom widget that displays search statistics (hits number and processing time).
Usage
import { connectStats } from 'instantsearch.js/es/connectors';
const customStats = connectStats(
(renderOptions, isFirstRender) => {
const { nbHits, processingTimeMS, query, widgetParams } = renderOptions;
const { container } = widgetParams;
container.innerHTML = `
<div>
<strong>${nbHits.toLocaleString()}</strong> results found
${query ? ` for "<em>${query}</em>"` : ''}
in <strong>${processingTimeMS}ms</strong>
</div>
`;
}
);
search.addWidgets([
customStats({
container: document.querySelector('#stats'),
}),
]);
Connector Options
This connector has no specific options.
Render Options
The number of hits in the result set.
The number of sorted hits in the result set (when using Relevant sort).
Indicates whether the index is currently using Relevant sort and is displaying only sorted hits.
The number of pages computed for the result set.
The maximum number of hits per page returned by Algolia.
The time taken to compute the results inside the Algolia engine.
The query used for the current search.
The options passed to the connector.