SearchScroll Java API SearchContextMissingException

SearchScroll Java API SearchContextMissingException

因此,无论出于何种原因,我正在尝试 运行 一个简单的 java 应用程序,以从另一个索引 ("myindex") 创建一个全新的索引来修复一些数据但它似乎崩溃并说 "could not find search context id=5322" 并且它说每个分片(每个节点?)的不同 ID。

我有 3 个节点。 3 台带弹性搜索的服务器 运行ning.

我按照这里的例子:

https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.4/java-search-scrolling.html

并确保我有 65K 的限制:

https://www.elastic.co/guide/en/elasticsearch/reference/5.4/file-descriptors.html

main(String[] args){
final TimeValue keepAlive = TimeValue.timeValueSeconds(90L);

SearchResponse scrollResp = client.prepareSearch("myindex").setScroll(keepAlive)
                    .setSize(100).get();

    do
    {
        for(SearchHit hit : scrollResp.getHits().getHits())
        {
        i++;
        // do something here to prepare data for later rewriting to new index
        }
      scrollResp = client.prepareSearchScroll(scrollResp.getScrollId())
                        .setScroll(keepAlive)
                        .execute().actionGet();
    } while(scrollResp.getHits().getHits().length != 0);
    System.out.println("Storing entries...");
    /// store some of this info
 }

我转述了错误:

SearchContextMissingException, Caused by: org.elasticsearch.search.SearchContextMissingException: No search context found for id [5031530] at org.elasticsearch.search.SearchService.findContext(SearchService.java:480) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:450)

can't find id=45233 in node-2... inner exception: can't find id=52363 node-3

所以我没有隔离问题,但由于可能的原因问题已解决:

  1. 内存锁在所有 3 个节点服务器上的 elasticsearch.yml 中设置为 true
  2. 在所有 3 个节点服务器上 elasticsearch.yml 中的 nofile lock 设置为 true
  3. 临时在所有 3 节点服务器上完全复制。