askorama / orama

🌌 Fast, dependency-free, full-text and vector search engine with typo tolerance, filters, facets, stemming, and more. Works with any JavaScript runtime, browser, server, service!

Home Page:https://docs.orama.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The sorting of search results randomly changes order after running the update function

hawkup opened this issue · comments

Describe the bug

When using a custom document ID and after running the update function, the ordering of search results randomly changes.

Here's a screen recording comparing the behavior between using a custom document ID and an auto-generated document ID.

CleanShot.2567-02-13.at.14.15.51.mp4

To Reproduce

Link to code example: https://codesandbox.io/p/sandbox/zealous-lederberg-mc48tf?file=%2Fsrc%2FApp.tsx%3A30%2C52

  1. Create a schema with a custom document ID.
  2. Insert data with a custom document ID.
  3. Search with sorting (using another field, in my case, I use createdAt for sorting). The results from the search are ordered correctly.
  4. Run the update function to update one entity.
  5. Search with the same parameters again. The ordering of the results has changed.

Expected behavior

When using a custom document ID and after running the update function, the ordering of search results should not change.

Environment Info

OS: macOS Ventura 13.4.1
node: 18.19.0
orama: 2.0.5

Affected areas

Search

Additional context

No response

@allevo could you take a look when you have a moment?

Thanks for the report!
I reproduced the issue in a test and sent a PR to fix it!

@allevo Thank you so much. Tested it on the latest version, and it's fixed.