Azure Cognitive Search vector field type Collection(Edm.Single) issue with OpenAI integration

I need help with connecting Azure Cognitive Search to OpenAI’s gpt-4o-128k model for vector searching. When I make API calls, I keep getting an error about the vector field type.

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

Here’s my request payload:

{
    "model": "gpt-4o-128k",
    "messages": [
        {
            "role": "user",
            "content": "how do I start a business?"
        },
        {
            "role": "system",
            "content": "You are a helpful support agent who provides detailed and caring assistance to users. Focus on understanding what they need and give them useful answers"
        }
    ],
    "data_sources": [
        {
            "type": "azure_search",
            "parameters": {
                "index_name": "company_index",
                "query_type": "vector",
                "embedding_dependency": {
                    "type": "deployment_name",
                    "deployment_name": "text-embedding-ada-002"
                },
                "fields_mapping": {
                    "content_fields": [
                        "document_text",
                        "combined_data"
                    ],
                    "vector_fields": [
                        "document_text",
                        "combined_data"
                    ]
                }
            }
        }
    ]
}

The error I get back:

{
    "error": {
        "requestid": "a15bc892-7d4f-3e88-92af",
        "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)"
    }
}

Any ideas what I’m doing wrong here?

Your error’s coming from the index schema, not the API call. Those fields you mentioned - ‘document_text’ and ‘combined_data’ - sound like regular text fields, not vector fields. When you set up your Azure Cognitive Search index, you need actual vector fields with the right config: ‘type’: ‘Collection(Edm.Single)’, ‘searchable’: false, ‘retrievable’: true, and ‘dimensions’ set to 1536 for the text-embedding-ada-002 model. I hit this exact same problem last month and had to rebuild my whole index with proper vector field definitions. Check your index schema in the Azure portal - I bet you’ll see your current fields are just regular string fields.

Your fields mapping is the problem. You’re pointing vector_fields to ‘document_text’ and ‘combined_data’ - those are text fields, not vector fields. You need separate fields in your Azure Cognitive Search index that actually store embeddings. These have to be Collection(Edm.Single) type with vector search dimensions that match your embedding model (1536 for text-embedding-ada-002). Right now you’re trying to use text fields as vector fields, which doesn’t work. First create proper vector fields in your index schema, then update vector_fields to point to those.

i think ur mixing up field types. vector_fields should be of type Collection(Edm.Single) for the search to work. try creating a field like “embedding_vector” instead of using text fields. check your index config again.