我是Elasticsearch的新手,并且一直在手动输入数据,直到此时为止.例如,我做过这样的事情:
$ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
Run Code Online (Sandbox Code Playgroud)
我现在有一个.json文件,我想把它编入Elasticsearch.我也尝试过类似的东西,但没有成功:
curl -XPOST 'http://jfblouvmlxecs01:9200/test/test/1' -d lane.json
Run Code Online (Sandbox Code Playgroud)
如何导入.json文件?是否需要先采取步骤以确保映射正确?
我对Elasticsearch很新.我正在尝试编写一个将按字段分组并计算总和的查询.在SQL中,我的查询看起来像这样:
SELECT lane, SUM(routes) FROM lanes GROUP BY lane
我在ES中看到这样的数据:
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "TUeWFEhnS9q1Ukb2QdZABg",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M05",
"routes": 4047
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "owVmGW9GT562_2Alfru2DA",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M03",
"routes": 4065
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "JY9xNDxqSsajw76oMC2gxA",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M05",
"routes": 3056
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "owVmGW9GT345_2Alfru2DB", …Run Code Online (Sandbox Code Playgroud)