2014-03-13 35 views
0

我試圖在我的Es索引中插入日期時間值。但我目前不明白。ElasticSearch字段類型「date」插入日期('Y-m-d H:i:s')

如果我使用例如自定義映射「eventDate」=>「date」,並嘗試用「eventDate」=> date('Ymd H:i:s')索引一個文檔,我得到這個錯誤:

IllegalArgumentException [Invalid format:\「2014-03 -13 15:36:15 \「15:36:15 \」格式不正確]; 「,」status「:400}

我明白了,但是我不知道我應該改變什麼?!?!我想在以後的Kibana直方圖中使用這個字段,所以它必須是日期字段

ES中的文檔,我看到的日期格式是這樣的:「YM-DTH:我:■」 這是什麼「T」在中間?而且我怎麼能這個指數正是這樣

!?

感謝您的幫助。 marc

回答

1

T只是日期的分隔符。有關這方面的更多信息,請參見Wikipedia

A single point in time can be represented by concatenating a complete date expression, the letter T as a delimiter, and a valid time expression. For example "2007-04-05T14:30". If a time zone designator is required, it follows the combined date and time. For example "2007-04-05T14:30Z" or "2007-04-05T12:30-02:00".

Either basic or extended formats may be used, but both date and time must use the same format. The date expression may be calendar, week, or ordinal, and must use a complete representation. The time expression may use reduced accuracy. It is permitted to omit the 'T' character by mutual agreement.

而對於索引錯誤,儘量把T分隔符,也是時區(你可以把Z,這意味着UTC)。之後,你應該可以在Kibana中繪製圖表。

相關問題