[英]What is the alternative for es.mapping.timestamp in ElasticSearch 7.x?
ElasticSearch 的官方文檔說:
包含文檔時間戳的文檔字段/屬性名稱。 要指定常量,請使用格式。 不適用於 Elasticsearch 6.0+ 索引版本,但將繼續支持 5.x 索引版本及以下版本。
因此,當我嘗試使用它來確保我的索引分別具有時間戳時,我會收到此錯誤。
org.elasticsearch.hadoop.EsHadoopIllegalArgumentException:無法在 ES 6.x 及更高版本中的索引/更新請求上使用時間戳。 請刪除 [es.mapping.timestamp] 設置。
我試過的代碼是:
df.write.format("org.elasticsearch.spark.sql").config("es.mapping.timestamp","timestamp")mode("overwrite").save("indexname/doc")
時間戳是 Spark dataframe 中的一個字段。 我也用 saveToEs 嘗試過,得到了同樣的錯誤。 有什么方法可以通過使用任何其他字段在 ElasticSearch 7.x 中做到這一點?
我對 Spark 不太熟悉,但不推薦使用_timestamp
元字段,因此您必須使用在 ES 映射中定義的date
字段——根據您的規范,其格式可以是epoch_second
或epoch_millis
:
PUT your_index_name
{
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "epoch_second"
}
}
}
}
在那之后,我想您將不再需要.config("es.mapping.timestamp","timestamp")
,因為您的文檔中的timestamp
值將在 ES 中直接解析為支持其各自日期查詢的date
字段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.