为什么有时Elasticsearch滚动或搜索会返回一组无法单独检索的文档ID?

时间:2018-07-04 12:12:08

标签: elasticsearch elassandra

我看到一个奇怪的问题,Elasticsearch滚动或搜索API返回了一组文档,这些文档我再也无法通过id获取。我正在使用Elassandra(Cassandra + ES),它正在使用Elasticsearch作为二级索引存储。 Cassandra记录上有TTL,由于TTL而被丢弃,但是id在Elasticsearch中仍然存在。为什么会有这种奇怪的行为?我确实在Elasticsearch上刷新并强制合并了相应的索引,但这没有帮助。

1 个答案:

答案 0 :(得分:0)

好的。我发现了问题。 Cassandra上的TTL字段会删除Cassandra上的记录,但是基于Elasticsearch构建的自定义二级索引Elassandra不会被该机制删除。实际上,TTL在更高版本的ES上不再存在。需要从ES中显式删除文档,或者我们需要在ES上使用时间分区索引,以便可以删除旧索引。