Hi all
I’m using Vector Search and am looking to be able to pre-filter with $eq or similar and have it not be case sensitive. Given that Regex is not supported currently in Vector Search, example below,
Does anyone have a solution that may work?
Use case would be a filtering on a name where it is saved as “Jack” and we filter with “jack”.
[
{
$vectorSearch: {
queryVector: [-0.020156775, -0.024996493, 0.010778184....],
path: "seovoc:embeddings",
numCandidates: 20,
index: "vector_index",
limit: 20,
filter: {
name: {
$regex: "/JacK/i"
}
}
}
}
]
Hi @Ethan_kleinlugtenbelt! Thank you for the question, I can answer from the POV of the MongoDB product team.
We are looking at adding support for different types of lexical filters like regex and queryString to the $vectorSearch prefilter. In the meantime, you should be able to use a regex prefilter using the queryString operator as a filter within the knnBeta operator.
[
"$search": {
"index": "vector_index_knnvector",
"knnBeta": {
"filter": {
"compound": {
"must": [
{
"queryString": {
"query": "CAMBRIDGE AND test~2 NOT ALAN",
"defaultPath": "descriptions"
}
},
]
},
"vector": [...],
"path": "seovoc:embeddings",
"k": 2000
}
},
{"$limit": 200}
]
Note that you will have to build a new index using the knnVector field type if you want to take this approach.
I will call out that while both of this operator and field type are deprecated, we would not EOL them before support for this and a few other types of filter in $vectorSearch are supported. Once that day comes you should be able to switch back to using $vectorSearch.
Hopefully this helps, and happy to answer any follow-ups you might have.
Hello @Henry_Weller, have regex filters been added to the $vectorSearch prefilters?
I am trying the following operation and getting an error: