An Azure NoSQL database service for app development.
Hello !
Thank you for posting on MS Learn Q&A.
I think your filter field is not indexed because a text index is not needed for {"field_name": "String Value"}. You need a normal MongoDB ascending index on the filter field in addition to the DiskANN vector index.
For exact match filtering with Cosmos DB MongoDB vCore vector search you need to create a normal index on the filter field. DiskANN only indexes the vector path and it does not automatically optimize metadata filters.
db.yourCollection.createIndex({ field_name: 1 })
Then keep the filter inside the $search.cosmosSearch.filter section:
db.yourCollection.aggregate([
{
"$search": {
"cosmosSearch": {
"path": "contentVector",
"vector": queryVector,
"k": 10,
"lSearch": 100,
"filter": {
"field_name": { "$eq": "String Value" }
}
}
}
}
])
DiskANN filtering creates both the vector index and a separate index on the filter field for example is_open: 1 specifically so filtered vector search can be optimized.
https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search