Skip to content

Use cosine similarity in SQL query for embeddings#344

Merged
v-dirichards merged 1 commit intoMicrosoftDocs:mainfrom
Giorgi:patch-1
Jan 22, 2026
Merged

Use cosine similarity in SQL query for embeddings#344
v-dirichards merged 1 commit intoMicrosoftDocs:mainfrom
Giorgi:patch-1

Conversation

@Giorgi
Copy link
Copy Markdown
Contributor

@Giorgi Giorgi commented Jan 15, 2026

The DiskAnn index is created for vector_cosine_ops but the query was using inner product <#>

@prmerger-automator
Copy link
Copy Markdown
Contributor

@Giorgi : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 7985e9f:

✅ Validation status: passed

File Status Preview URL Details
articles/postgresql/azure-ai/generative-ai-azure-openai.md ✅Succeeded

For more details, please refer to the build report.

@v-regandowner
Copy link
Copy Markdown
Contributor

@mulander

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator Bot added the aq-pr-triaged C+L Pull Request Review Team label label Jan 15, 2026
@markingmyname
Copy link
Copy Markdown
Member

#assign: @markingmyname

@markingmyname
Copy link
Copy Markdown
Member

#sign-off

@prmerger-automator
Copy link
Copy Markdown
Contributor

Invalid command: '#sign-off'. Only the assigned author of one or more file in this PR can sign off. @mulander

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the SQL query was using the wrong vector similarity operator. The DiskAnn index is created with vector_cosine_ops for cosine similarity, but the query was incorrectly using the inner product operator.

Changes:

  • Changed the vector similarity operator from inner product <#> to cosine similarity <=> in the ORDER BY clause of the embedding similarity search query

@v-dirichards v-dirichards merged commit 65c509f into MicrosoftDocs:main Jan 22, 2026
9 checks passed
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.

6 participants