algolia / instantsearch

⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.59k stars 503 forks source link

Duplicate entries on useInfiniteHits hits property #6182

Open andretauffer opened 2 months ago

andretauffer commented 2 months ago

🐛 Current behavior

We import the useInfiniteHits from react-instantsearch-core in a react native project. On our infinite hits display we've noticed the seldom appearance of duplicates of items shown previously in the hits. Our investigation has found that the hits property found in the API returned by useInfiniteHits had the duplicates of items that had the exact same objectID, and were the same in every other aspect but ranking. The duplicates show up in consecutive queries usually: image And their only difference shown in ranking: image

We've attempted to use your distinct property, but we could only use it with objectID which doesn't seem to work and that shouldn't be necessary either. My questions here are:

  1. Is there some ranking configuration or hook configuration that we're missing to fix this scenario?
  2. Our platform constantly adds entries to the index. Could ranking be affected by new entries being added to the index? How would that affect ongoing queries?
  3. Is there a way for the algolia search to filter objectID duplicates before return? We wouldn't like to filter it ourselves on client side, since on an infinite scroll, at some point it could get to be a costly operation.

🔍 Steps to reproduce

Scroll down on a view that uses useInfiniteHits. I believe for it to actually be triggered you should be adding entries to the index that could affect the ranking, from one query to the next.

Live reproduction

Don't really know how to reproduce it on a sandbox. Read the steps to reproduce

💭 Expected behavior

We'd expect that data doesn't get duplicated. Hopefully the query would automatically exclude duplicates based on objectID, but otherwise an opt-in feature could allow you to remove that on query time.

Package version

react-instantsearch-core 7.3.0

Operating system

No response

Browser

No response

Code of Conduct