我有一个Opensearch集群,运行3个节点。有时我需要搜索最近创建的文档(创建后不到1秒)。为此,我减少了refresh_interval
,并使用refresh=wait_for
来确保文档可用。但有时文档仍然不可用(即使在10秒后)。我唯一认识到的是,当时我的索引状态是黄色的-一些碎片无法分配。文件丢失的原因是什么?
我的索引请求:
final IndexRequest indexRequest = new IndexRequest(index);
indexRequest.id(id);
indexRequest.source(data, XContentType.JSON);
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);
final IndexResponse indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
我试图修复的东西:
- refresh_interval为100 ms
- 使用refresh=wait_for的API调用
1条答案
按热度按时间oewdyzsn1#
根本原因是,我的群集状态在某个时候变成了红色。修复后,问题没有再次发生。