簡體   English   中英

彈性搜索中的TTL

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM