首页 文章

弹性搜索创建基于时间的索引

提问于
浏览
3

根据Time-Based Data,使用这种方法主要有两种情况 . 首先是日志记录,es与Logstash集成,默认情况下每天都会创建一个新的索引 .

但是,我处于创建社交网络活动索引的第二个条件,索引将自动每3个月创建一次,这意味着索引名称将为 data-01data-04data-07 .

我有很多搜索弹性elastic search reference2.1elastic search : The Definitive Guide . 我什么都没有帮助 .

希望有人能给我一些线索或提示 .

1 回答

  • 0

    您可以使用Curator创建基于时间的索引 . 策展人允许您创建/删除索引,创建别名等 .

    所以基本上你可以做到以下几点:

    1> create an alias which will be used to save data into ES.
    2> create a script which will create an index using the current date.
    3> detach last months index from the save alias
    4> attached the newly created index to your save alias.
    5> drop older indices more thatn 30/60/90 days or according to your requirements.
    6> write a cron job which will run every month and run this script above.
    

    因此,您每个月都会将数据保存到新索引中 .

    7> create another alias for searching with something like indexname* so that it searches across all your existing indices.
    

相关问题