在window的cmd窗口下,按照教程输入如下命令:
<pre name="code" class="java">curl -XPOST 'localhost:9200/books/solr/1' -d '{"title":"Apache Solr 4 Cookbook", "published": 2012}'
发现报错,报错信息如下:
<pre name="code" class="java">curl: (6) Could not resolve host: 'localhost
curl: (6) Could not resolve host: published
curl: (3) [globbing] unmatched close brace/bracket in column 5
如果我们输入以下命令:
curl -XPOST "localhost:9200/books/solr/1" -d "{"title":"Apache Solr 4 Cookbook", "published": 2012}"
报错信息如下:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "json_parse_exception",
"reason": "Unrecognized token 'Apache': was expecting ('true', 'false' or 'null') at
[Source: org.elasticsearch.common.io.stream.InputStreamStreamInput@217e1; line: 1, column: 27]"
}
},
"status": 400
}curl: (6)Couldnotresolvehost: Solr
解决方法如下:
curl -XPOST "localhost:9200/books/solr/1" -d "{"""title""":"""Apache Solr 4 Cookbook""", """published""": 2012}"