Skip to content

fix(matrixone): apply score threshold to vector search - #39784

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
csurong:fix/matrixone-score-threshold
Aug 2, 2026
Merged

fix(matrixone): apply score threshold to vector search#39784
crazywoola merged 1 commit into
langgenius:mainfrom
csurong:fix/matrixone-score-threshold

Conversation

@csurong

@csurong csurong commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #39783

  • Normalize MatrixOne L2 distances into similarity scores with 1 / (1 + distance).
  • Filter vector search results using score_threshold.
  • Include the similarity score in returned document metadata.
  • Add unit coverage for the threshold behavior.

Screenshots

Not applicable (backend-only change).

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Tests

  • uv run --project api pytest -q -o addopts='' api/providers/vdb/vdb-matrixone/tests/unit_tests/test_matrixone_vector.py (15 passed)
  • Ruff check and format check for the changed files
  • Pyrefly check for the changed backend file

@csurong
csurong requested a review from QuantumGhost as a code owner July 30, 2026 03:36
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 56.78% 56.78% +0.00%
Strict coverage 56.31% 56.31% +0.00%
Typed symbols 37,092 37,092 0
Untyped symbols 28,468 28,467 -1
Modules 3091 3091 0

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 2, 2026
@crazywoola
crazywoola added this pull request to the merge queue Aug 2, 2026
Merged via the queue into langgenius:main with commit 8a2cf65 Aug 2, 2026
34 checks passed
fatelei pushed a commit that referenced this pull request Aug 2, 2026
Co-authored-by: caosurong <surong.cao@thinkingdata.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MatrixOne vector search ignores score_threshold

2 participants