Skip to content

Change score of query-less prefetch to 1.0#7347

Merged
coszio merged 1 commit intodevfrom
queryless-score-is-1
Oct 6, 2025
Merged

Change score of query-less prefetch to 1.0#7347
coszio merged 1 commit intodevfrom
queryless-score-is-1

Conversation

@coszio
Copy link
Contributor

@coszio coszio commented Oct 6, 2025

There is a use-case where a filter is to be used as a primary source, and then use vector search as fallback. With this PR, assuming cosine similarity which has output of 0-1, a query like this can be made.

{
  "prefetch": [
    {
      "filter": { "must": { "key": "description", "match": { "text": ... } } }, // full-text filter
    },
    { 
      "query": ..., // vector query
    }
  ],
  "query": { "formula": { "sum": ["$score[0]", "$score[1]"] } }
}

This way, results from the full-text filter will rank higher, but if the filter does not have enough results, we'll still have results from vector search.

Alternatively, something that can be done without this PR is to use the condition within the formula query again. But this method will check the same condition twice, and has a worse DX.

{
  "prefetch": [
    {
      "filter": { "must": { "key": "description", "match": { "text": ... } } }, // full-text filter
    },
    { 
      "query": ..., // vector query
    }
  ],
  "query": { "formula": { 
    "sum": [
      { "key": "description", "match": { "text": ... } }, // same condition again
      "$score[1]", 
    ]
  }
}

@coszio coszio merged commit 33bd50e into dev Oct 6, 2025
16 checks passed
@coszio coszio deleted the queryless-score-is-1 branch October 6, 2025 17:47
@qdrant qdrant deleted a comment from coderabbitai bot Oct 7, 2025
@timvisee timvisee mentioned this pull request Nov 14, 2025
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.

2 participants