Defaults Hits Before Search

How to select defaults hits to display at first page before to start the search?

Hi @arnaudjnn,

Welcome to the Algolia Community!
I’m not sure I understand your question, but I believe you are trying to set a default search term.

If you are using InstantSearch you can do something like this:

const search = instantsearch({
  indexName: 'instant_search',
  searchClient,
  searchParameters: {
    query: 'lenovo'
  },
});

I’ve created a codesandbox for you here:

Notice the searchParameters starting at line 11 in the app.js file.

Let me know if I misunderstood your question. Otherwise, let us know how this works for you!

Hello Cindy,

Thanks for the answer. Not a default search term.
Here is my search :
42

I want to select the 12 brands to display before the user start the search (instead id order). Let’s say in a second time it could be the user most liked brands.

Hi @arnaudjnn,

In that case, you can use ‘filters’ to select the brands:

const search = instantsearch({
  indexName: 'instant_search',
  searchClient,
  searchParameters: {
    //query: 'lenovo',
    filters: 'brand:Samsung OR brand:Apple',
  },
});

I’ve updated the codesandbox here.

Does that help?