Skip to content

Fix AzureDocumentDB score threshold for EuclideanDistance - #56

Merged
adamsitnik merged 1 commit into
CommunityToolkit:mainfrom
Empiree:fix/documentdb-euclidean-score-threshold
Sep 28, 2026
Merged

adamsitnik merged 1 commit into
CommunityToolkit:mainfrom
Empiree:fix/documentdb-euclidean-score-threshold

Conversation

@Empiree

@Empiree Empiree commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

For EuclideanDistance DocumentDB returns a distance, so the score threshold filter has to use $lte, not $gte. Now it picks operator by distance function, same as the Cosmos provider does

Removed the TestScoreThreshold override so the conformance test runs again. Tested locally with documentdb-local, it fails before the fix and passes after. Also bumped the provider version to 1.0.1

Fixes #6

@Empiree

Empiree commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review comments remain, and the corrected behavior is covered by the restored conformance test.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Azure DocumentDB score-threshold filtering for Euclidean distance and bumps the provider version to 1.0.1.

Changes:

  • Uses $lte for Euclidean distance and $gte for similarity scores.
  • Re-enables the score-threshold conformance test.
  • Passes the configured distance function into threshold mapping.
File Description
MEVD/​test/​AzureDocumentDB.ConformanceTests/​DocumentDBDistanceFunctionTests.cs Re-enables score-threshold testing.
MEVD/​src/​AzureDocumentDB/​DocumentDBCollectionSearchMapping.cs Selects the threshold operator by distance function.
MEVD/​src/​AzureDocumentDB/​DocumentDBCollection.cs Passes the configured distance function to threshold mapping.
MEVD/​src/​AzureDocumentDB/​AzureDocumentDB.csproj Updates the provider version to 1.0.1.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The bug fix looks perfect, big thanks for providing it @Empiree !

@adamsitnik
adamsitnik merged commit c6e39c9 into CommunityToolkit:main Sep 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CosmosMongo EuclideanDistance doesn't correctly filter by score threshold (returns all results)

3 participants