首页 > 解决方案 > 为什么有时 Elasticsearch 滚动或搜索会返回一组无法单独检索的文档 ID?

问题描述

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

标签: elasticsearchelassandra

解决方案


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


推荐阅读