Mitesh Prajapati
Mitesh Prajapati

Reputation: 53

Error: Azure Search requires a vector field of type Collection(Edm.Single) when integrating with OpenAI

I'm trying to integrate Azure Cognitive Search with OpenAI's gpt-4o-128k deployment to perform vector searches. I'm sending a request with my index and vector details to OpenAI. However, I'm encountering the following error:

API Endpoint https:///openai/deployments/gpt-4o-128k/chat/completions?api-version=2024-10-21

Request

    "model": "gpt-4o-128k",
    "messages": [
        {
            "role": "user",
            "content": "how to create firm?"
        },
        {
            "role": "system",
            "content": "You are a customer support assistant tasked with providing clear, empathetic, and efficient support to customers. Your goal is to understand the customer inquiry, provide accurate information"
        }
    ],
    "data_sources": [
        {
            "type": "azure_search",
            "parameters": {
                "index_name": "my index",
                "query_type": "vector",
                "embedding_dependency": {
                    "type": "deployment_name",
                    "deployment_name": "text-embedding-ada-002"
                },
                "fields_mapping": {
                    "content_fields": [
                        "content",
                        "merged_content"
                    ],
                    "vector_fields": [
                        "content",
                        "merged_content"
                    ]
                }
            }
        }
    ]
}

Response

    "error": {
        "requestid": "b04de723-9c8c-4d99-85ff",
        "code": 400,
        "message": "An error occurred when calling Azure Cognitive Search: Azure Search: Please assign a proper column/field for vector search. It should be of type Collection(Edm.Single)"
    }
}

Thanks!!

Upvotes: 0

Views: 70

Answers (1)

JayashankarGS
JayashankarGS

Reputation: 8140

You are passing same fields for both content_fields and vector_fields, which is giving you the error.

content_fields is meant for the fields having the text data to model and vector_fields is for having embedded vectors of the same data passed to content_fields.

So, you need to create 2 new fields "content_vector","merged_content_vector" in you index of type Collection(Edm.Single) which the type used to store vectors.

enter image description here

Like shown in above image create 2 fields and vector profile.

Next you need azure OpenAI embedding skillset to embed the text content and add outputfieldsmappings in indexer to add vector data into vector fields.

Learn more about vectorization here.

After successfully creating vector fields you add data source like below.

    "data_sources": [
        {
            "type": "azure_search",
            "parameters": {
                "index_name": "my index",
                "query_type": "vector",
                "embedding_dependency": {
                    "type": "deployment_name",
                    "deployment_name": "text-embedding-ada-002"
                },
                "fields_mapping": {
                    "content_fields": [
                        "content",
                        "merged_content"
                    ],
                    "vector_fields": [
                        "content_vector",
                        "merged_content_vector"
                    ]
                }
            }

Upvotes: 0

Related Questions