【发布时间】:2021-11-16 23:37:37
【问题描述】:
我正在寻找一种方法来为我的 Elasticsearch 索引中的文档设置 TTL,最好是通过我的 Spring Boot 应用程序中的属性来设置
我试图用 curl 来做,但我得到了这个错误
curl --location --request PUT 'http://localhost:9200/order_index/_mapping/order_doc' \
--header 'Content-Type: application/json' \
--data-raw '{
"_ttl": {
"enabled": true,
"default": "24h"
}
}'
错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [_ttl : {default=24h, enabled=true}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [_ttl : {default=24h, enabled=true}]"
},
"status": 400
}
【问题讨论】:
-
当我搜索文档时,似乎 _ttl 在 Elasticsearch 中可用。在当时的版本中,我不知道此功能。
-
感谢@P.J.Meisch elastic.co/guide/en/elasticsearch/reference/current/…
-
这个帖子可能有帮助:stackoverflow.com/a/40945912/4604579
-
是的,从版本 5 开始就不可能了discuss.elastic.co/t/ttl-documents/162712/7
标签: elasticsearch spring-data-elasticsearch