0
我試圖使用Java API ElasticSearch查詢Elasticsearch複雜的查詢,我的查詢是:使用Java API
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邏輯是:
選擇不同(clientip)從表其中timestamp '2015-08-20'和'2015-08-21'之間,請求'/ v2/brand%'和響應='200'
如何使用Java API實現它? 請指導我是ElasticSearch的新手。提前致謝!
你爲什麼不開始https://www.elastic.co/guide/en/elasticsearch/client/java-api/ current/search.html並首先想出一些解決方案? – bittusarkar