正在使用Elasticsearch服务器并使用curl命令进行发布,在Windows命令行中获取数据。
当我尝试使用curl -XPUT命令发布数据时,数据似乎已插入。但是当我使用curl-XGET查询数据时,我没有得到数据,只有索引号等标题信息。请参阅下面的查询和结果。
curl -XPUT "<server location>/megacorp/emp/1" -d "{""first_name"" : ""John"",""last_name"" : ""Smith"",""age"" : "25"}"
{"_index":"megacorp","_type":"emp","_id":"1","_version":1,"created":true}
curl -XPUT "<server location>/megacorp/emp/2" -d "{""first_name"" : ""Jane"",""last_name"" : ""Cooper"",""age"" : "35"}"
{"_index":"megacorp","_type":"emp","_id":"2","_version":1,"created":true}
curl -XPUT "<server location>/megacorp/emp/3" -d "{""first_name"" : ""Bradleey"",""last_name"" : ""Cooper"",""age"" : "40"}"
{"_index":"megacorp","_type":"emp","_id":"3","_version":1,"created":true}
curl -XGET "<server location>/megacorp/emp/_search?q=last_name:Cooper"
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"megacorp","_type":"emp","_id":"2","_score":1.0},{"_index":"me
gacorp","_type":"emp","_id":"3","_score":1.0}]}}
答案 0 :(得分:0)
试试这个:curl -XGET "<server location>/megacorp/emp/_search?q=last_name:Cooper&_source=true"