2017-04-12 66 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.