0

私はelasticsearchを初めて使用し、フィルタリングされた検索を行いたいです:私のマッピングの一部は次のようになります:

  "_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_at を持ち、 を持つすべてのインデックスがgte:"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 に答える