Atlas vector search similarity threshold

Is there a way to set a threshold similarity score for vector similarity search? E.g only return vectors if score is > 0.7. Else if no vector meets the requirement, return nothing.

Thank you for submitting the question! We don’t support this in the prefilter today, but you can always use a subsequent $match stage as a post-filter considering the vector score.

{
    "$vectorSearch": {
        "index": "vector_index",
        "path": "vector",
        "queryVector": [0.456, 0.311, ...],
        "numCandidates": 100,
        "limit": 10
    }
},
{
    "$addFields": {"score": {"$meta": "searchScore"}}
},
{
    "$match": {"score": {"gte": 0.7}}
},
{
    "$project": {"vector": 0}
},

We are considering exploring threshold-based search in the future, as this is supported in Lucene. I have created a UserVoice ticket for this feature, feel free to vote on it and I will update this thread with any product updates to this effect.

I had to make 2 changes to make it work.

searchScore => vectorSearchScore
gte => $gte

{
    "$vectorSearch": {
        "index": "vector_index",
        "path": "vector",
        "queryVector": [0.456, 0.311, ...],
        "numCandidates": 100,
        "limit": 10
    }
},
{
    "$addFields": {"score": {"$meta": "vectorSearchScore"}}
},
{
    "$match": {"score": {"$gte": 0.7}}
},
{
    "$project": {"vector": 0}
},