Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PosgreSQL hybrid search #958

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

SignalRT
Copy link

This PR Includes:

  • Text search index
  • Hybrid Search configuration
  • Vector or hybrid search

Motivation and Context (Why the change? What's the scenario?)

Vector search do not provide the best results in an important number of scenarios. Hybrid search provides better results.

High level description (Approach, Design)

This change includes a new parameter for activate hybrid search on PostgreSQL extension. This parameters defaults to the previous implementation (vector search).
The search will use vector search or hybrid search depending on the parameter.

Include:
- Text search index
- Hybrid Search configuration
- Vector or hybrid search
@SignalRT
Copy link
Author

@microsoft-github-policy-service agree

@SignalRT SignalRT marked this pull request as ready for review December 29, 2024 12:24
@SignalRT SignalRT requested a review from dluc as a code owner December 29, 2024 12:24
@@ -175,7 +183,8 @@ public async Task CreateTableAsync(
{this._colContent} TEXT DEFAULT '' NOT NULL,
{this._colPayload} JSONB DEFAULT '{{}}'::JSONB NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_tags ON {tableName} USING GIN({this._colTags});
CREATE INDEX IF NOT EXISTS {tableName}_idx_tags ON {tableName} USING GIN({this._colTags});
CREATE INDEX IF NOT EXISTS {tableName}_idx_content ON {tableName} USING GIN(to_tsvector('english',{this._colContent}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the language be configurable?

Comment on lines +473 to +475
FROM {tableName}, plainto_tsquery('english', @query) query
WHERE {filterSqlHybridText} AND to_tsvector('english', {this._colContent}) @@ query
ORDER BY ts_rank_cd(to_tsvector('english', {this._colContent}), query) DESC
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto: language should be configurable

Copy link
Collaborator

@dluc dluc left a comment

Choose a reason for hiding this comment

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

Looks almost ready to merge, only a few minor tweaks, please see the comments inline. Two most important:

  • configurable language
  • documenting the new SQL and the hard coded calculations

@dluc dluc added the waiting for author Waiting for author to reply or address comments label Jan 8, 2025
@dluc
Copy link
Collaborator

dluc commented Jan 29, 2025

Looks like the PR got stale, with some unsolved errors and comments. We might have to archive it unless someone can kindly complete the task.

@dluc dluc added the stale Inactive, possibly abandoned label Jan 29, 2025
@SignalRT
Copy link
Author

Looks like the PR got stale, with some unsolved errors and comments. We might have to archive it unless someone can kindly complete the task.

I will resolve the comments this weekend.

Add parametrization to text search language dictionary and parametrization of the Reciprocal Ranked Fusion "k-nearest neighbor" to score results of Hybrid Search
Copy link
Author

@SignalRT SignalRT left a comment

Choose a reason for hiding this comment

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

I finished to review the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive, possibly abandoned waiting for author Waiting for author to reply or address comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants