[PR #31658] feat(qdrant): implement full-text search with multi-keyword support #33341

Closed
opened 2026-02-21 20:53:06 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31658

State: closed
Merged: Yes


Resolve #31657

Summary

When using Qdrant's search_by_full_text method with multiple keywords (e.g., "apple banana"), the search only returns documents containing all keywords instead of documents containing any keyword.

For example:

Searching "apple" returns documents A (with "apple")
Searching "banana" returns documents B (with "banana")
Searching "apple banana" only returns documents containing both keywords, missing A and B

This happens because Qdrant's MatchText uses AND logic by default, unlike Elasticsearch/OpenSearch which use OR logic for multi-word match queries.

Root Cause:

Qdrant's MatchText with multiple words uses AND logic (all words must match)

The original docstring incorrectly stated "BM25" - Qdrant < 1.10 doesn't support native BM25

Current Qdrant image is langgenius/qdrant:v1.8.3

Solution:

Search each keyword separately and merge results with deduplication

This aligns with the behavior of other vector databases (ES/OpenSearch)

Screenshots

uv run --project api pytest api/tests/integration_tests/vdb/qdrant/test_qdrant.py

Before After
Test fail: Searching "apple banana" returns only docs with both keywords Test success: Searching "apple banana" returns docs with any keyword (union of results)

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 and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/31658 **State:** closed **Merged:** Yes --- Resolve #31657 ## Summary When using Qdrant's search_by_full_text method with multiple keywords (e.g., "apple banana"), the search only returns documents containing all keywords instead of documents containing any keyword. For example: Searching "apple" returns documents A (with "apple") Searching "banana" returns documents B (with "banana") Searching "apple banana" only returns documents containing both keywords, missing A and B This happens because Qdrant's MatchText uses AND logic by default, unlike Elasticsearch/OpenSearch which use OR logic for multi-word match queries. #### Root Cause: Qdrant's MatchText with multiple words uses AND logic (all words must match) The original docstring incorrectly stated "BM25" - Qdrant < 1.10 doesn't support native BM25 Current Qdrant image is `langgenius/qdrant:v1.8.3` ### Solution: Search each keyword separately and merge results with deduplication This aligns with the behavior of other vector databases (ES/OpenSearch) ## Screenshots `uv run --project api pytest api/tests/integration_tests/vdb/qdrant/test_qdrant.py ` | Before | After | |--------|-------| | Test fail: Searching "apple banana" returns only docs with both keywords | Test success: Searching "apple banana" returns docs with any keyword (union of results) | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:53:06 -05:00
yindo closed this issue 2026-02-21 20:53:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33341