安装成功后就是插入数据:

C:\Users\Administrator>curl -XPUT "localhost:9200/films/md/2?pretty" -d {\"id\":
1,\"tag\":\"good\"}

可以通过curl命令简单的插入这条数据来测试,成功的话可以看到以下结果:

{
"_index" : "films",
"_type" : "md",
"_id" : "1",
"_version" : 3,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : false
}

一开始经常出现的一个错误是:

{
"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 'good': was expecting ('true', 'false' or '
null')\n at [Source: org.elasticsearch.common.io.stream.InputStreamStreamInput@7
22349c2; line: 1, column: 16]"
}
},
"status" : 400
}

反复检查json语句并没有错误,后来才发现需要在'"'引号前加入斜杠,否则会被默认为boolean值或者数字,出现无法解析json的错误。