2017-04-12 68 views
0

我想創建一個只有一個分片從Windows操作系統的索引。我從elastic website得到了代碼我已經將簡單的引號改爲double和3,並且我的curl看起來像這樣:curl -XPUT「localhost:9200/twitter?pretty」-H「Content-Type:application/JSON」 -d { 「設置」:{ 「索引」:{ 「number_of_shards」:1, 「number_of_replicas」:2}}}彈性搜索5.3用一個分片創建索引

當運行此我得到了以下錯誤:

{ 
"error" : { 
"root_cause" : [ 
    { 
    "type" : "parse_exception", 
    "reason" : "Failed to parse content to map" 
    } 
], 
"type" : "parse_exception", 
"reason" : "Failed to parse content to map", 
"caused_by" : { 
    "type" : "json_parse_exception", 
    "reason" : "Unexpected character ('s' (code 115)): was expecting double-quote to start field name\n at [Source: [email protected]; line: 1, column: 3]" 
} 
}, 
"status" : 400 
} 

我在做什麼錯?

+0

它從小提琴手4的魅力 – Radu

回答

0
curl -XPUT "localhost:9200/twitter?pretty" \ 
-H "Content-Type: application/json" \ 
-d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":2}}}' 

嘗試,你需要引用您的數據(-d)

+0

加入簡單的qoute我得到一個錯誤的原因:「壓縮機檢測只能在一些xcontent字節或壓縮的xcontent字節上調用」 – Radu

+0

@Radu刪除'-H'選項或你應該將數據提供爲'json'文件而不是'string'。 – avr

+0

@Radu - 我不知道這個,你猜我猜Elasticsearch有問題。如果我是你,我會重新安裝Elasticsearch並重新創建索引。 – mikeb

2

正如我熟悉的postman操作這裏有雲:

郵差

選擇PUT方法

localhost:9200/twitter

移動到郵遞員的主體部分點擊RAW單選按鈕,然後從下拉菜單旁邊binary單選按鈕

現在你只需要在JSON格式發送設置中選擇JSON

{"settings":{"index":{"number_of_shards":1,"number_of_replicas":2}}} 

note: don't use quotes while sending the JSON.