2017-05-26 46 views
0

因此,無論出於何種原因,我試圖運行一個簡單的java應用程序來從另一個索引(「myindex」)創建一個全新的索引來修復一些數據,但它似乎崩潰並說「找不到搜索上下文id = 5322「,它說每個分片(每個節點?)都有不同的ID。SearchScroll Java API SearchContextMissingException

我有3個節點。 3個運行elasticsearch的服務器。

我跟着這裏的例子:

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

回答

0

所以我不是孤立的問題,但問題是固定的,由於可能的原因:

  1. MEMLOCK設置爲true elasticsearch.yml在所有3個節點服務器版
  2. NOFILE鎖設置爲true elasticsearch所有3個節點服務器上的.yml
  3. 臨時對所有3個節點服務器進行完全複製。