向Azure搜索索引添加新文档时出错

时间:2016-12-27 19:18:54

标签: json azure azure-search

我有一个包含Edm.StringCollection(Edm.String)类型字段的索引。我想要另一个具有相同字段的索引加上另一个类型为Edm.Double的字段。当我创建这样的索引并尝试添加相同的值(加上新添加的Edm.Double值),就像我对第一个索引所做的那样,我收到以下错误:

{
    "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"
    }
}

有谁知道这个错误意味着什么?我尝试在互联网上寻找它,但我找不到任何与我的情况相关的东西。我发送给新索引的示例请求如下所示:

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"
    }]
}

旧索引是相同的,但它没有“weight”参数。

编辑:我使用门户创建了索引,所以我没有确切的JSON来创建索引,但字段大致如下:

   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 个答案:

答案 0 :(得分:2)

我收到错误的原因是因为我犯了一个错误,并且在索引的实际类型为Collection(Edm.String)时尝试发送Edm.String

相关问题