[英]Is there a way to set TTL on a document within AWS Elasticsearch utilizing python library?
[英]TTL in elasticsearch
我正在使用elasticsearch python客户端来创建和存储数据到aws elasticsearch实例。
def create_index():
"""
create mapping of data
"""
mappings = '''
{
"tweet":{
"_ttl":{
"enabled": true,
"default": "2m"
},
"properties": {
"text":{
"type": "string"
},
"location":{
"type": "geo_point"
}
}
}
}
'''
# Ignore if index already exists
es.indices.create(index='tweetmap', ignore=400, body=mappings)
如上所述,现在我希望记录在2分钟后自动删除,但它们是持久的。
可能的原因是什么?
我定义映射的方式出错,修正如下所示:
mappings = '''
{
"mappings":{
"tweet":{
"_ttl":{
"enabled": true,
"default": "1d"
},
"properties": {
"text":{
"type": "string"
},
"location":{
"type": "geo_point"
}
}
}
}
}
'''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.