Filtering to the subdocuments in the pre-filter stage of a vector search

Hi all, I am implementing vector search in my project and I am facing this issue!

This is a sample document in my database
[{
“_id”: “572d08ee1_1”,
“custom_fields”: [
{
“key”: “23453”,
“value”: [
“1”
]
},
{
“key”: “78157”,
“value”: [
“1”
]
},
{
“key”: “51740”,
“value”: [
“new”
]
}
],
}]

The query below is the one I executed, but it throws an error.

“com.mongodb.MongoCommandException: Command failed with error 8 (UnknownError): ‘PlanExecutor error during aggregation :: caused by :: “filter[0]” must be a boolean, objectId, number, string, date, uuid, or null’ on server”

{
$vectorSearch: {
index: “vector_index”,
path: “CourseEmbeddings”,
filter: {
$or: [
{
“custom_fields.key”: “23453”,
“custom_fields.value”: { $eq: [1] }
}
]
},
queryVector: [
-0.0072121937, -0.030757688, 0.014948666
],
numCandidates: 150,
limit: 10
}
}

Is there a way to apply filtering to the subdocuments in the pre-filter stage of a vector search?

1 Like