Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search 如何定期删除弹性搜索索引?_Search_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Lucene_Autosuggest_Search Suggestion - Fatal编程技术网 elasticsearch,lucene,autosuggest,search-suggestion,Search,elasticsearch,Lucene,Autosuggest,Search Suggestion" /> elasticsearch,lucene,autosuggest,search-suggestion,Search,elasticsearch,Lucene,Autosuggest,Search Suggestion" />

Search 如何定期删除弹性搜索索引?

Search 如何定期删除弹性搜索索引?,search,elasticsearch,lucene,autosuggest,search-suggestion,Search,elasticsearch,Lucene,Autosuggest,Search Suggestion,我每天都创建索引来存储搜索历史记录,我在应用程序中使用这些索引进行建议,这也有助于我根据历史记录进行建议 现在我只能维持最后10天的历史。那么Elastic search中是否有允许我定期创建和删除索引的功能呢?我不知道elasticsearch是否有这样的内置功能,但您可以通过cron作业实现您想要的功能 一个示例策展人命令是: Curator 3.x语法[已弃用]: curator --host <IP> delete indices --older-than 10 --pref

我每天都创建索引来存储搜索历史记录,我在应用程序中使用这些索引进行建议,这也有助于我根据历史记录进行建议


现在我只能维持最后10天的历史。那么Elastic search中是否有允许我定期创建和删除索引的功能呢?

我不知道elasticsearch是否有这样的内置功能,但您可以通过cron作业实现您想要的功能

一个示例
策展人
命令是:

Curator 3.x语法[已弃用]:

curator --host <IP> delete indices --older-than 10 --prefix "index-prefix-" --time-unit days  --timestring '%Y-%m-%d'
curator--主机删除索引--早于10--前缀“index prefix-”--时间单位天数--时间字符串“%Y-%m-%d”
策展人5.1.1语法:

curator_cli --host <IP> --port <PORT> delete_indices --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":10},{"filtertype":"pattern","kind":"prefix","value":"index-prefix-"}]'
curator_cli--host--port delete_index--filter_list'[{“filtertype”:“age”,“source”:“creation_date”,“direction”:“older”,“unit”:“days”,“unit_count”:10},{“filtertype”:“pattern”,“kind”:“prefix”,“value”:“index prefix-”}
每天使用cron作业运行此命令,以删除名称以
索引前缀-
开头且位于
的Elasticsearch实例上的早于10天的索引:

有关curator命令行选项的更多信息,请参阅:

有关cron使用的更多信息,请参阅:

我不知道elasticsearch是否有这样的内置功能,但通过使用cron作业,您可以实现您想要的功能

一个示例
策展人
命令是:

Curator 3.x语法[已弃用]:

curator --host <IP> delete indices --older-than 10 --prefix "index-prefix-" --time-unit days  --timestring '%Y-%m-%d'
curator--主机删除索引--早于10--前缀“index prefix-”--时间单位天数--时间字符串“%Y-%m-%d”
策展人5.1.1语法:

curator_cli --host <IP> --port <PORT> delete_indices --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":10},{"filtertype":"pattern","kind":"prefix","value":"index-prefix-"}]'
curator_cli--host--port delete_index--filter_list'[{“filtertype”:“age”,“source”:“creation_date”,“direction”:“older”,“unit”:“days”,“unit_count”:10},{“filtertype”:“pattern”,“kind”:“prefix”,“value”:“index prefix-”}
每天使用cron作业运行此命令,以删除名称以
索引前缀-
开头且位于
的Elasticsearch实例上的早于10天的索引:

有关curator命令行选项的更多信息,请参阅:

有关cron使用的更多信息,请参阅:
我唯一能想到的就是使用数据数学:

从某种意义上说,你可以做到这一点:

DELETE <logs-{now%2Fd-10d}>
删除
但由于url编码的原因,这在curl中不起作用。您可以在curl中执行以下操作:

curl -XDELETE 'localhost:9200/<logs-%7Bnow%2Fd-10d%7D>'
curl-XDELETE'localhost:9200/'
这两个示例都删除了10天前的索引。它不能帮助您删除超过10天的索引,请不要认为这是可能的。他们的搜索不是触发器,也不是弹性搜索


因此,我会坚持与策展人一起从事cron工作,但你也有这个选择。

我唯一能想到的就是使用数据数学:

从某种意义上说,你可以做到这一点:

DELETE <logs-{now%2Fd-10d}>
删除
但由于url编码的原因,这在curl中不起作用。您可以在curl中执行以下操作:

curl -XDELETE 'localhost:9200/<logs-%7Bnow%2Fd-10d%7D>'
curl-XDELETE'localhost:9200/'
这两个示例都删除了10天前的索引。它不能帮助您删除超过10天的索引,请不要认为这是可能的。他们的搜索不是触发器,也不是弹性搜索


因此,我会坚持与馆长一起担任cron工作,但你也有这个选择。

感谢alpert的回复。我的应用程序中有这样的功能。我正在从Elasticsearch中查找任何内置功能。您可以使用
\u ttl
,但它不会仅删除文档索引。
\u ttl
在Elasticsearch 2.x中不推荐使用。馆长仍然是一条路要走。上面的答案是Curator3.x语法。馆长4现在外出并使用YAML配置文件。感谢阿尔伯特的回复。我的应用程序中有这样的功能。我正在从Elasticsearch中查找任何内置功能。您可以使用
\u ttl
,但它不会仅删除文档索引。
\u ttl
在Elasticsearch 2.x中不推荐使用。馆长仍然是一条路要走。上面的答案是Curator3.x语法。馆长4现在外出使用YAML配置文件。