0

我是弹性搜索的新手,我想做一个过滤搜索:我的映射的一部分是这样的:

  "_index" : "project", 
  "_type" : "flat_order", 
  "_id" : "795", 
  "_score" : 2.1372108, 
  "fields" : { 
    "status" : "canceled", 
    "created_at" : "2012-01-04 12:48:48", 
    "updated_at" : "2012-02-21 07:19:35" 
  } 
}, { 
  "_index" : "project", 
  "_type" : "flat_order", 
  "_id" : "803", 
  "_score" : 2.1372108, 
  "fields" : { 
    "status" : "canceled", 
    "created_at" : "2012-01-04 12:50:54", 
    "updated_at" : "2012-02-21 07:19:35" 
  } 

我希望所有的索引都在一个范围内 created_atgte:"2012-01-01 00:00:00",lte:"2012-02-01 00:00:00"并且有status :"cancelled" or "confirmed".

提前致谢

4

1 回答 1

1

得到了解决方案:

$ curl -X GET http://localhost:9200/project/flat_order/_search?pretty=true -d '{
  "fields": [
    "created_at",
    "status"
  ],
  "query": {
    "filtered": {
      "query": {
        "range": {
          "create‌​d_at": {
            "gte": "2012-01-01 00:00:00",
            "lte": "2012-02-01 00:00:00"
          }
        }
      },
      "filter": {
        "or": [
          {
            "term": {
              "status": "canceled"
            }
          },
          {
            "term": {
              "status": "con‌​firmed"
            }
          }
        ]
      }
    }
  }
}

'

于 2012-05-18T08:09:03.747 回答