algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

Offseting search doesn't work #3628

Closed Haans001 closed 1 year ago

Haans001 commented 1 year ago

🐛 Bug description

Hello, we are trying to use useConfigure hook to offset our search by some number. However passing offset property to hook args object, doesn't seem to do anything. Hook usage:

 useConfigure({
    hitsPerPage: 1000,
    offset: 58,
  });

hitsPerPage property is working as expected.

It's also worth to mention that offset isn't even working on the library playground. https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/react-instantsearch

🔍 Bug reproduction

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/react-instantsearch
  2. Add offset property to Configure hitsPerPage={8} /> component
  3. See that there is no change in search results.

💭 Expected behavior

Search results will get offseted with offset property given to useConfigure hook or <Configure /> component.

Environment

Haroenv commented 1 year ago

Offset is meant to be used in tandem with length, not with hitsPerPage, all widgets inside React InstantSearch Hooks (pagination, infiniteHits, hitsPerPage) therefore use only hitsPerPage.

What's the experience you're creating?

Haans001 commented 1 year ago

We are trying to build some kind of nested list and to make it look good, we have to parse get around 1000 documents per page. The idea was to make custom pagination by manipulating offset by 1000 * page number. Using pagination hooks is not possible because we cannot load more then 1000 hits to pagination in meilisearch client.

Haroenv commented 1 year ago

The limitation to 1000 hits is reasonable (it's the same for Algolia) to keep performance at a decent pace. What you could do is use page / hitsPerPage in the application, but transform those to length/offset in the search client directly.

As your question involves Meilisearch, and not Algolia, I'll close this issue, as the limitation isn't on React InstantSearch' side further

Have a nice day!