Getting the total number of search results for multiple indicies

I am using Instant Search with multiple indices. Search results are displayed with hit count first and then the individual hits, one after the other. I like to display the total number of hit counts and then a list with all search results with pagination.

Can anybody tell me how to approach this?

Hi @werner, Do you want the total for all indices? Do you want to combine the results from the multiple indices into one list? If so, you may need to make some customizations to the instant search widgets. Could you provide more information about what, exactly, you are trying to accomplish with the multiple indices results? Can you provide a code snippet or codesandbox to demonstrate how you are making the call? We have a starter codesandbox for instantsearch here.

Hi @cindy.cullen , yes, I like to show the total of all indices and combine the results of multiple indices. This is a request from our designer who likes to make the results page simple and non-confusing.

I am using InstantSearch. I am using some code from your examples:

const HitsInIndex = ({ index }) => {
  return (
    <Index indexName={index.name}>
      <HitCount />
      <Hits className="Hits" hitComponent={PageHit} />
    </Index>
  );
};

HitsInIndex.propTypes = {
  index: PropTypes.shape().isRequired,
};

const SearchResult = props => {
  const { indices, className } = props;

  return (
    <div className={className}>
      <div className="columns">
        {indices.map(index => (
          <HitsInIndex index={index} key={index.name} />
        ))}

        <Pagination />
      </div>
    </div>
  );
};

In this code example I like to delete the <HitCount /> component in <HitsInIndex /> and build my own inside <SearchResult />. But I don’t know who to get the raw number of hits per Index.