qdrant / qdrant/qdrant

Qdrant gives different and incorrect results with DatetimeRange filter

Open
#5,595 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
34.7k
Forks
2.7k
Avg merge
1d 18h
Merged PRs (30d)
187

Description

To my knowledge, semantic similarity score is absolute, not relative.

However, using the DatetimeRange filter, I get different results when the date range is expanded. The correct document disappears even though it should be within the range.

eg, given the question and searching for range > 2022:

from qdrant_client.http import models as qdrant_models
from langchain_community.vectorstores import Qdrant

# skip loading of vector store

vector_store.similarity_search(question,k=15, 
filter=qdrant_models.Filter(
must=qdrant_models.FieldCondition(key='meeting_date',
range=qdrant_models.DatetimeRange(gte='2022-01-01')))
)

This gives (doc id | doc title | score)

[('CR-ID-REPLACED', <title replaced>, 0.63587),
('CR-ID-REPLACED', <title replaced>, 0.62937194),
('CR-ID-REPLACED', <title replaced>, 0.629144),
('CR-ID-REPLACED', <title replaced>, 0.6280967),
('CR-ID-REPLACED',<title replaced>, 0.6271694)]

Which is incorrect. The relevant doc is not retrieved. However, if i include a max date, the result is correct.

vector_store.similarity_search(question,k=15,
filter=qdrant_models.Filter(
must=qdrant_models.FieldCondition(key='meeting_date',
range=qdrant_models.DatetimeRange(gte='2022-01-01', lte='2023-01-01'))))

[('CR-ID-REPLACED', <title replaced> 0.66140205), # <-- correct document!
('CR-ID-REPLACED', <title replaced>, 0.6271694),
('CR-ID-REPLACED', <title replaced>, 0.6211362),
('CR-ID-REPLACED', <title replaced>, 0.62014866),
('CR-ID-REPLACED', <title replaced>, 0.6195655)]

I also get the correct docs above if i dont set any date range filters. eg,

vector_store.similarity_search(question,k=15)

What I don't understand is why does this behavior happen?

  • The correct doc has the highest score, but it completely disappear when we dont include a max date even though it should logically be in the same set?
  • Furthermore, None of the documents retrieved in the 2nd query are the same! I expect at least some overlap?

This is boggling the mind. Would appreciate any help!

versions

Qdrant version v1.12.4

Using the langchain qdrant abstraction

langchain-community==0.2.17
qdrant-client==1.12.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two DatetimeRange-filtered similarity_search calls and the unfiltered call with Qdrant v1.12.4, qdrant-client 1.12.1, and langchain-community 0.2.17. Compare the returned documents and scores, then trace the relevant Qdrant filtering and search behavior; done means the discrepancy is explained and a regression test demonstrates consistent results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
databases, machine-learning, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.