Error while adding new documents to Azure Search index

4.2k views Asked by At

I have an index with a couple of fields of type Edm.String and Collection(Edm.String). I want to have another index with the same fields plus another field of type Edm.Double. When I create such an index and try to add the same values (plus the newly added Edm.Double value) as I did to the first index, I'm getting the following error:

{
    "error": {
        "code": "",
        "message": "The request is invalid. Details: parameters : An unexpected 'StartArray' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.\r\n"
    }
}

Does anyone know what this error means? I tried looking for it on the Internet but I couldn't find anything related to my situation. A sample request I'm sending to the new index looks like this:

POST https://myservicename.search.windows.net/indexes/newindexname/docs/index?api-version=2016-09-01

{
    "value": [{
        "@search.action": "upload",
        "keywords": ["red", "lovely", "glowing", "cute"],
        "name": "sample document",
        "weight": 0.5,
        "id": "67"
    }]
}

The old index is the same but it doesn't have the "weight" parameter.

Edit: I created the index using the portal, so I don't have the exact JSON to create the index, but the fields are roughly like this:

   Field                     Type                            Attributes        Analyzer
---------------------------------------------------------------------------------------
      id               Edm.String                      Key, Retrievable   
    name               Edm.String   Searchable, Filterable, Retrievable   Eng-Microsoft
keywords   Collection(Edm.String)   Searchable, Filterable, Retrievable   Eng-Microsoft
  weight               Edm.Double                  Filterable, Sortable
1

There are 1 answers

1
halileohalilei On

The reason I got the error was because I made a mistake and was trying to send a Collection(Edm.String) when the actual type on the index was Edm.String.