2017-09-25 11 views
0

yyyy-dd-mm形式の日付フィールドに03-2015のようなelasticsearchを照会します。日付フィールドにmm-yyyy形式で検索する弾性検索クエリ

は、私はこのように試してみました、しかし、それはすべてのエラーを与えていないworked.Itsは、それが0のレコード

curl -XPOST "http://localhost:9200/myindex/mytype/_search?pretty" -d '{ 
"query": { 
    "bool": { 
     "must": [ 
      { 
       "range": { 
        "deliverydate": { 
         "gte": "03-2015", 
         "lte": "03-2015", 
         "format": "mm-yyyy" 
        } 
       } 
      } 

     ] 
    } 
} 

} 「

私のサンプル文書は、この

{ 
"took": 38, 
"timed_out": false, 
"_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
}, 
"hits": { 
    "total": 10, 
    "max_score": 1, 
    "hits": [ 
     { 
      "_index": "myindex", 
      "_type": "mytype", 
      "_id": "33924", 
      "_score": 1, 
      "_source": { 
       "id": 33924, 
       "deliverydate": "2015-03-14", 
       "name":"New test order" 
      } 
     } 
     ] 
    } 
ですが返されませんでした

}

誰でもこれを手伝ってください。これはelasticsearchデータの有効な検索ですか?

答えて

0

あなたの形式は(MM代わりのmm)正しくない、これは我々がelasticsearchフィールドのフォーマットを与えるOR検索クエリの形式を与える必要がありする必要はworking..doされていない

curl -XPOST "http://localhost:9200/myindex/mytype/_search?pretty" -d '{ 
"query": { 
    "bool": { 
     "must": [ 
      { 
       "range": { 
        "deliverydate": { 
         "gte": "03-2015", 
         "lte": "04-2015", 
         "format": "MM-yyyy" 
        } 
       } 
      } 

     ] 
    } 
}}' 
+0

番号でなければなりません? – Developer

+0

どのようなエラーが表示されますか? 'deliverydate'フィールドを使ってサンプル文書を表示してください。 – Val

+0

これは私のサンプルドキュメントです。 { "取った":38、 "TIMED_OUT":偽、 "_shards":{ "合計":5、 "成功":5、 が "失敗":0 }、 "ヒット":{ "合計":10、 "max_score":1、 "ヒット":[ { "_index": "myindex"、 "_type": "MYTYPE"、 "_id": "33924"、 "_score":1、 "_source":{ "id":33924、 "deliverydate": "2015-03-14"、 "名前": "新しいテストオーダー" – Developer