Previously I used Azure Cosmos DB for MongoDB (VCore) free tier for RAG and used the vector filtering process (included in Azure and also in my Python script) and everything worked perfectly.
I created a new project following the same processes above, but with an Azure Cosmos DBM25 tier, 2 (Burstable) vCores and using the same subscription and I receive the error:
pymongo.errors.OperationFailure: $filter is not supported for vector search yet., full error: {'ok': 0.0, 'errmsg': '$filter is not supported for vector search yet.', 'code': 115, 'codeName': 'CommandNotSupported'}
**
To make the filters work, I use the following codes:
1°:
db.command({
"createIndexes": "{}".format(env['COLLECTION']),
'indexes': [
{
'name': 'VectorSearchIndex',
'key': {
"vector": "cosmosSearch"
},
'cosmosSearchOptions': {
'kind': 'vector-ivf',
'numLists': 1,
'similarity': 'COS',
'dimensions': 1536
}
}
]
})
2°:
db.command( {
"createIndexes": <MyCollection>,
"indexes": [ {
"key": {
"metadata": 1
},
"name": "metadata_filter"
}
]
}
)
and I received this result:
for i in collection.list_indexes():
print(i)
result:
SON([('v', 2), ('key', SON([('_id', 1)])), ('name', '_id_')]) SON([('v', 2), ('key', SON([('vector', 'cosmosSearch')])), ('name', 'VectorSearchIndex'), ('cosmosSearchOptions', SON([('kind', 'vector-ivf'), ('numLists', 1), ('similarity', 'COS'), ('dimensions', 1536)]))]) SON([('v', 2), ('key', SON([('metadata', 1)])), ('name', 'metadata_filter')])