[英]TTL in elasticsearch
I am using the elasticsearch python client to create and store data to a aws elasticsearch instance. 我正在使用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)
As defined above, now I am expecting the records to be deleted automatically after 2 minutes, however they are persisting. 如上所述,现在我希望记录在2分钟后自动删除,但它们是持久的。
What could be the possible reason ? 可能的原因是什么?
There was an error with the way I had defined mappings, corrected it as shown below: 我定义映射的方式出错,修正如下所示:
mappings = '''
{
"mappings":{
"tweet":{
"_ttl":{
"enabled": true,
"default": "1d"
},
"properties": {
"text":{
"type": "string"
},
"location":{
"type": "geo_point"
}
}
}
}
}
'''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.