2015-12-24 29 views
0

我有一個文件與現場 "creationDate": "2015-12-13T22:00:00.000+0300" 此字段映射是:不正確的時區

"creationDate": { 
    "type": "date", 
    "format": "dateOptionalTime" 
} 

我想創建中不存在格式直方圖聚集和格式輸出日期與此查詢:

{ 
    "size": 0, 
    "aggs": { 
    "docs": { 
     "filter": { 
     "and": { 
      "filters": [ 
      { 
       "range": { 
       "creationDate": { 
        "gte": "2015-12-23T00:00:00+02:00", 
        "lte": "2015-12-23T23:59:59+02:00" 
       } 
       } 
      } 
      ] 
     } 
     }, 
     "aggs": { 
     "deep": { 
      "nested": { 
      "path": "actions" 
      }, 
      "aggs": { 
      "histogram": { 
       "date_histogram": { 
       "field": "actions.creationDate", 
       "interval": "1h", 
       "format": "yyyy-MM-dd'T'HH:mm:ssZ", 
       "time_zone": "+03:00" 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 

但作爲結果我得到的結果在UTC格式:

{ 
    "key_as_string": "2015-12-13T19:00:00+0000", 
    "key": 1450033200000, 
    "doc_count": 1 
    } 

我不明白爲什麼存在格式轉換爲UTC,我怎樣才能得到預期的格式?我認爲「time_zone」參數應該解決這個問題,但沒有

回答

1

我假設你正在使用Elasticsearch 1.x,因爲這似乎是在2.x中得到改進的預期行爲。請參閱此評論here以及在2.x分支中添加此增強功能的問題。

+0

謝謝你是對的 – user2971752