Skip to content

fix(hybrid search results): fixed hybrid search by removing redundant…#731

Merged
SaraVieira merged 5 commits intooramasearch:mainfrom
rajesh-jonnalagadda:fix-730-hybrid-search-result-issue
Jun 11, 2024
Merged

fix(hybrid search results): fixed hybrid search by removing redundant…#731
SaraVieira merged 5 commits intooramasearch:mainfrom
rajesh-jonnalagadda:fix-730-hybrid-search-result-issue

Conversation

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor

@rajesh-jonnalagadda rajesh-jonnalagadda commented Jun 6, 2024

/claim #730
/fixes #730

… slicing before filtering

results were sliced and then filtered, causing incorrect document return and an upper-bounded count value. Now, filtering is done first to ensure accurate total count and correct document retrieval.

demo video:
https://www.loom.com/share/63cc6cfee37c434596d79750977d5dff

… slicing before filtering

results were sliced and then filtered, causing incorrect document return and an upper-bounded count
value. Now, filtering is done first to ensure accurate total count and correct document retrieval.
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orama-docs ❌ Failed (Inspect) Jun 10, 2024 1:59pm

@micheleriva
Copy link
Copy Markdown
Contributor

Hi, can you please add some tests? Thank you

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

Hi, can you please add some tests? Thank you

In project, we already has test cases.
packages/orama/tests/search.hybrid.test.ts

… to the limit

if we set a limit of 10, the total count of the results will not exceed 10, even if there are more
matching documents. This means you don't get the actual total number of results that match your
search criteria, but rather a maximum of the limit value.
@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

Hi, can you please add some tests? Thank you

Added the test cases. can you please check now

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

@micheleriva are there any other changes required from my side to proceed further? let me know if needed.

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

@micheleriva Hey, could you please review the PR changes? if any changes are needed please let me know

t.equal(page3.count, 20)

//ideally this has to show 2. not sure why it is like this
// t.equal(page1.count, 20)
Copy link
Copy Markdown

@nicolastoulemont nicolastoulemont Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The count is supposed to be equal to the total number of documents matching the query, not the paginated amount of documents returned, otherwise you might as well just use the hits.length property

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the second test case?. that count should also be 20

Copy link
Copy Markdown
Contributor Author

@rajesh-jonnalagadda rajesh-jonnalagadda Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused. in the below example. the count is 2 even though the total count is 20.
https://codesandbox.io/p/sandbox/objective-sun-kzs96j?file=%2Fsrc%2Findex.ts

Uploading Screenshot from 2024-06-10 15-06-10.png…

and also it is mentioned in the issue that there is an issue with
The count value is upper-bounded to the limit.

Copy link
Copy Markdown

@nicolastoulemont nicolastoulemont Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I wasn't clear enough by:

total number of documents matching the query

I meant the total number of documents matching the query regardless of the offset / limit

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

@nicolastoulemont Hey, reverted the test cases to their original values. can you please check now

})
})

t.test('should fix the issue realted #730', async (t) => {
Copy link
Copy Markdown

@nicolastoulemont nicolastoulemont Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Please write a better test name, describing in the code the intended behavior

limit: 2,
offset: 2,
});
const page4 = await search(db, {
Copy link
Copy Markdown

@nicolastoulemont nicolastoulemont Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Not sure the page4 is necessary here tbh

Copy link
Copy Markdown

@nicolastoulemont nicolastoulemont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, would love maintainers reviews tho

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

@micheleriva
I wanted to follow up on the latest changes, where I’ve addressed all the comments and made the requested changes. Could you please take a moment to review the updates? Your feedback would be greatly appreciated.

@SaraVieira
Copy link
Copy Markdown
Contributor

Hey!

Sorry for the delay on getting back to you on this, this looks great! Merging it now

@SaraVieira SaraVieira merged commit b11262e into oramasearch:main Jun 11, 2024
@micheleriva
Copy link
Copy Markdown
Contributor

Hi @rajeshj11 please give us one day to process this.

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

Hi @rajeshj11 please give us one day to process this.

yeah sure, no rush. Just want to know where it is blocked.

@rajesh-jonnalagadda
Copy link
Copy Markdown
Contributor Author

@micheleriva may I know the status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hybrid search: Missing documents and inaccurate count value with a where clause

4 participants