2016-12-27 103 views
1

我有一個索引,其中有幾個字段的類型爲Edm.StringCollection(Edm.String)。我想要另一個具有相同字段的索引加上另一個類型爲Edm.Double的字段。當我創建這樣一個指數,並嘗試添加像我一樣的第一指標,我發現了以下錯誤相同的值(以及新添加Edm.Double值):將新文檔添加到Azure時出錯搜索索引

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

舊索引是相同的,但它沒有「權重」參數。

編輯:我使用的門戶網站,所以我沒有確切的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 
+0

你可以分享'newindexname'索引的定義嗎?特別是字段及其數據類型。 –

+0

我無法重現該問題。我創建了一個相同的索引,並使用PowerShell發送相同的索引請求,並且工作正常。你能仔細檢查你在這裏發佈的JSON究竟是你在請求中發送的嗎? –

+0

@BruceJohnston原來我在從門戶創建索引時犯了一個錯誤,並且當我打算選擇'Collection(Edm.String)'時爲字段選擇了'Edm.String'。我重新創建了索引,一切都很好。對不起,因爲一個微不足道的錯誤而浪費時間。 – halileohalilei

回答

1

我得到的原因的錯誤是因爲我犯了一個錯誤,並試圖發送一個Collection(Edm.String)當索引的實際類型爲Edm.String

相關問題