'vectors' in the request payload is not a valid parameter for the operation 'search'.

Ralf A 15 Reputation points
2023-11-17T10:09:53.5866667+00:00

Hello everyone!

I'm trying to set up a vector store within Azure Cognitive Search.

So far I created an index and added data to it, including a vectorized version of my text.

Next I want to query the index using a vector search.
To do that I followed a guide I found here:
https://learn.microsoft.com/en-us/azure/search/search-get-started-vector

POST https://{{search-service-name}}.search.windows.net/indexes/{{index-name}}/docs/search?api-version=2023-11-01
Content-Type: application/json
api-key: {{admin-api-key}}
{
    "count": true,
    "select": "HotelId, HotelName, Description, Category",
    "vectors": [
        {
            "value": [0.01944167, 0.0040178085
                . . . 
                010858015, -0.017496133],
            "k": 7,
            "fields": "DescriptionVector",
            "kind": "vector",
            "exhaustive": true
        }
    ]
}

I put together a Python function using the same schema:

endpoint = f'{service_name}/indexes/test-index/docs/search?api-version={api_version}'

    headers = {
        'Content-Type': 'application/json',
        'api-key': api_key
    }

    searchString = "test"

    payload = {
        "count": True,
        "select": "DocId, DocName, description, docText",
        "vectors": [
            {
                "value": CallOpenAI.createEmbedding(searchString),
                "k": 2,
                "fields": "docVector",
                "kind": "vector",
                "exhaustive": True
            }
        ]
    }

response = requests.post(endpoint, headers=headers, data=json.dumps(payload))

However running the query always results in this error message:
"The request is invalid. Details: The parameter 'vectors' in the request payload is not a valid parameter for the operation 'search'."

I tried both 2023-10-01-preview as well as 2023-11-01 to no avail.

I hope someone can help me figure out what I'm doing wrong.

Best regards
Ralf

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,106 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ralf A 15 Reputation points
    2023-11-17T14:34:27.3166667+00:00

    I found the solution here:
    https://learn.microsoft.com/en-us/rest/api/searchservice/documents/search-post?view=rest-searchservice-2023-11-01&tabs=HTTP

    Instead of vectors I used this definition:

    "vectorQueries": [
        {
          "kind": "vector",
          "vector": [
            0.103,
            0.0712,
            0.0852,
            0.1547,
            0.1183
          ],
          "fields": "descriptionEmbedding",
          "k": 5,
          "exhaustive": true
        }
      ]
    
    3 people found this answer helpful.

Your answer

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