Share via

Error when using the Cosmos Azure DB filter function with an OpenAI GPT

Brendon de Almeida Calazans 0 Reputation points
2024-10-09T17:11:06.3366667+00:00

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')])
Azure Cosmos DB
Azure Cosmos DB

An Azure NoSQL database service for app development.

Azure OpenAI Service
Azure OpenAI Service

An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.


1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 21,156 Reputation points Microsoft Employee Moderator
    2024-10-14T19:39:22.6466667+00:00

    @Brendon de Almeida Calazans

    Sorry for the delay in response to your question.

    Seems lie Looks like you haven't enabled the preview feature on your subscription yet. Please kindly follow the doc to enable the feature on your subscription.

    Enable the "filtering vector search" feature in the "Preview Features" tab of your Azure Subscription. Learn more about preview features here.

    Please comment below if you need more clarification and don't forget to mark as accept answer if the reply was helpful

    Regards,

    Oury


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.