2017-04-12 99 views
0

我有被髮送到elasticsearch服務器類似如下的要求:Elastisearch不治療的Unix時間戳爲有效的時間戳

http://localhost:9200/myindex/_bulk

然而時間戳沒有被識別爲文件時間戳和剛剛顯示出來任何有長期價值的領域。

Elasticsearch文檔說Unix時代是一個標準的時間格式,我不必爲此創建任何特殊的映射。

{ "index" : { "_type" : "regionserver.Regions" } } 
{ "@timestamp" : 1492, "type" : "regionserver.Regions", "region" : "1588230740", "table" : "meta", "storeCount" : 1, "storeFileCount" : 2, "memStoreSize" : 416, "storeFileSize" : 13453 } 

回答

0

你需要有明確的映射@timestamp場定義爲date類型以指數unix timestamp值,否則Elasticsearch將它們視爲long類型。所以索引unix timestamp值到@timestamp場之前,定義映射,如下圖所示:

PUT myindex 
{ 
    "mappings": { 
    "regionserver.Regions": { 
     "properties": { 
     "@timestamp": { 
      "type": "date" 
      } 
     } 
    } 
    } 
} 

希望這有助於!

+0

謝謝。我沒有試過這個。我避免了爲每個索引和每個文檔類型創建映射。 ElasticSearch是否允許全局設置,其中可以將名爲「@timestamp」的任何字段映射爲日期? –

+0

我想我要回答我的後續問題: 答案在模板中: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html –

+0

是,Elasticsearch'索引模板'就是這樣做的。 – avr