【发布时间】:2015-09-06 21:47:47
【问题描述】:
我正在尝试使用 Java API 查询 ElasticSearch,我的查询是:
curl -XGET 'http://localhost:9200/logstash-*/_search?search_type=count' -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and" : [
{
"range": {
"timestamp": {
"gte": "2015-08-20",
"lt": "2015-08-21",
"format": "yyyy-MM-dd",
"time_zone": "+8:00"
}
}
},
{"query": {
"match": {
"request": {
"query": "/v2/brand"
}
}
}
},
{"term": { "response" : "200"}
}
]
}
}
},
"aggs": {
"group_by_device_id": {
"terms": {
"field": "clientip"
}
}
}
}'
类似的sql逻辑是:
从时间戳在“2015-08-20”和“2015-08-21”之间的表中选择 distinct(clientip),请求类似于“/v2/brand%”且响应 =“200”
如何使用 Java API 来实现它? 请指导我是 ElasticSearch 的新手。提前致谢!
【问题讨论】:
-
你为什么不先从elastic.co/guide/en/elasticsearch/client/java-api/current/…开始想出一些解决方案呢?
标签: java elasticsearch