基于两个键获取elasticsearch结果

时间:2015-06-17 12:40:41

标签: elasticsearch

我希望所有“PayerAccountId”应该等于“123”并且“UsageStartDate”应该在范围内的文档[2015-05-01至2015-05-10]

我希望能像这样运行,

 curl -X GET http://192.168.1.3:9200/_all/_search -d '{"query" : {"match" : { "PayerAccountId:\"156023466485\" AND UsageStartDate:[2015-01-01 TO 2015-01-10]" }}}'

显然它没有任何建议

这是我的一个文档

    {
  "_index": "logstash-2015.04.01",
  "_type": "sam_billing_hourly",
  "_id": "ef06aeb5fbab7191a43335740779fc73b667ff0b",
  "_score": 1.0,
  "_source": {
    "@version": "1",
    "@timestamp": "2015-04-01T02:00:00.000Z",
    "Operation": "A",
    "PayerAccountId": "156023466485",
    "PricingPlanId": 482457,
    "RateId": 3035133,
    "RecordType": "LineItem",
    "UnBlendedCost": 4.0e-07,
    "UnBlendedRate": 4.0e-07,
    "UsageEndDate": "2015-04-01T03:00:00Z",
    "UsageQuantity": 1,
    "UsageStartDate": "2015-04-01T02:00:00Z",
    "UsageType": "DNS-Queries",
    "fingerprint": "ef06aeb5fbab7191a43335740779fc73b667ff0b"
  }

1 个答案:

答案 0 :(得分:1)

您需要query_string而不是match

{
  "query": {
    "query_string": {
      "query": "PayerAccountId:\"156023466485\" AND UsageStartDate:[2015-01-01 TO 2015-10-01]"
    }
  }
}