- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 searchScroll
从一个索引中获取超过 100k
文档,并在所有 100K
文档中再添加一个字段。然后再次将这些文档插入到另一个新索引中。
我正在使用SearchScroll
API,同时正在设置大小searchSourceBuilder.size(100)
,我已将大小增加到searchSourceBuilder.size(1000)
。在这两种情况下,处理 18100
文档(当 searchSourceBuilder.size(100) 时)和 21098
文档(当 searchSourceBuilder.size(1000) 时)后都会出现以下错误。
search_context_missing_exception","reason":"找不到 id 的搜索上下文
并且,错误在这一行抛出 searchResponse = SearchEngineClient.getInstance().searchScroll(scrollRequest);
请找到我完整的错误堆栈
Exception in thread "main" ElasticsearchStatusException[Elasticsearch exception
[type=search_phase_execution_exception, reason=all shards failed]]; nested: Elas
ticsearchException[Elasticsearch exception [type=search_context_missing_exceptio
n, reason=No search context found for id [388]]];
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestR
esponse.java:177)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLeve
lClient.java:573)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(R
estHighLevelClient.java:549)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighL
evelClient.java:456)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEn
tity(RestHighLevelClient.java:429)
at org.elasticsearch.client.RestHighLevelClient.searchScroll(RestHighLev
elClient.java:387)
at com.es.utility.DocumentIndex.main(DocumentIndex.java:101)
Suppressed: org.elasticsearch.client.ResponseException: method [GET], ho
st [http://localhost:9200], URI [/_search/scroll], status line [HTTP/1.1 404 Not
Found]
{"error":{"root_cause":[{"type":"search_context_missing_exception","reason":"No
search context found for id [390]"},{"type":"search_context_missing_exception","
reason":"No search context found for id [389]"},{"type":"search_context_missing_
exception","reason":"No search context found for id [392]"},{"type":"search_cont
ext_missing_exception","reason":"No search context found for id [391]"},{"type":
"search_context_missing_exception","reason":"No search context found for id [388
]"}],"type":"search_phase_execution_exception","reason":"all shards failed","pha
se":"query","grouped":true,"failed_shards":[{"shard":-1,"index":null,"reason":{"
type":"search_context_missing_exception","reason":"No search context found for i
d [390]"}},{"shard":-1,"index":null,"reason":{"type":"search_context_missing_exc
eption","reason":"No search context found for id [389]"}},{"shard":-1,"index":nu
ll,"reason":{"type":"search_context_missing_exception","reason":"No search conte
xt found for id [392]"}},{"shard":-1,"index":null,"reason":{"type":"search_conte
xt_missing_exception","reason":"No search context found for id [391]"}},{"shard"
:-1,"index":null,"reason":{"type":"search_context_missing_exception","reason":"N
o search context found for id [388]"}}],"caused_by":{"type":"search_context_miss
ing_exception","reason":"No search context found for id [388]"}},"status":404}
at org.elasticsearch.client.RestClient$1.completed(RestClient.ja
va:357)
at org.elasticsearch.client.RestClient$1.completed(RestClient.ja
va:346)
at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.
java:119)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerI
mpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.process
Response(HttpAsyncRequestExecutor.java:436)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputRe
ady(HttpAsyncRequestExecutor.java:326)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consume
Input(DefaultNHttpClientConnection.java:265)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputRea
dy(InternalIODispatch.java:81)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputRea
dy(InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputRead
y(AbstractIODispatch.java:114)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseI
OReactor.java:162)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEve
nt(AbstractIOReactor.java:337)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEve
nts(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(Ab
stractIOReactor.java:276)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIO
Reactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
$Worker.run(AbstractMultiworkerIOReactor.java:588)
at java.lang.Thread.run(Unknown Source)
Caused by: ElasticsearchException[Elasticsearch exception [type=search_context_m
issing_exception, reason=No search context found for id [388]]]
at org.elasticsearch.ElasticsearchException.innerFromXContent(Elasticsea
rchException.java:490)
at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchEx
ception.java:406)
at org.elasticsearch.ElasticsearchException.innerFromXContent(Elasticsea
rchException.java:435)
at org.elasticsearch.ElasticsearchException.failureFromXContent(Elastics
earchException.java:594)
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestR
esponse.java:169)
... 6 more
请找到我的java代码:
public class DocumentIndex {
private final static String INDEX = "documents";
private final static String ATTACHMENT = "document_attachment";
private final static String TYPE = "doc";
private static final Logger logger = Logger.getLogger(Thread.currentThread().getStackTrace()[0].getClassName());
public static void main(String args[]) throws IOException {
RestHighLevelClient restHighLevelClient = null;
Document doc=new Document();
logger.info("Started Indexing the Document.....");
try {
restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")));
} catch (Exception e) {
System.out.println(e.getMessage());
}
//Fetching Id, FilePath & FileName from Document Index.
SearchRequest searchRequest = new SearchRequest(INDEX);
searchRequest.types(TYPE);
final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L)); //part of Scroll API
searchRequest.scroll(scroll); //part of Scroll API
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
QueryBuilder qb = QueryBuilders.matchAllQuery();
searchSourceBuilder.query(qb);
searchSourceBuilder.size(100);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = SearchEngineClient.getInstance().search(searchRequest);
String scrollId = searchResponse.getScrollId(); //part of Scroll API
SearchHit[] searchHits = searchResponse.getHits().getHits();
long totalHits=searchResponse.getHits().totalHits;
logger.info("Total Hits --->"+totalHits);
//part of Scroll API -- Starts
while (searchHits != null && searchHits.length > 0) {
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId);
scrollRequest.scroll(scroll);
searchResponse = SearchEngineClient.getInstance().searchScroll(scrollRequest);
scrollId = searchResponse.getScrollId();
searchHits = searchResponse.getHits().getHits();
File all_files_path = new File("d:\\All_Files_Path.txt");
File available_files = new File("d:\\Available_Files.txt");
File missing_files = new File("d:\\Missing_Files.txt");
int totalFilePath=1;
int totalAvailableFile=1;
int missingFilecount=1;
Map<String, Object> jsonMap ;
for (SearchHit hit : searchHits) {
String encodedfile = null;
File file=null;
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
if(sourceAsMap != null) {
doc.setId((int) sourceAsMap.get("id"));
doc.setApp_language(String.valueOf(sourceAsMap.get("app_language")));
}
String filepath=doc.getPath().concat(doc.getFilename());
logger.info("ID---> "+doc.getId()+"File Path --->"+filepath);
try(PrintWriter out = new PrintWriter(new FileOutputStream(all_files_path, true)) ){
out.println("FilePath Count ---"+totalFilePath+":::::::ID---> "+doc.getId()+"File Path --->"+filepath);
}
file = new File(filepath);
if(file.exists() && !file.isDirectory()) {
try {
try(PrintWriter out = new PrintWriter(new FileOutputStream(available_files, true)) ){
out.println("Available File Count --->"+totalAvailableFile+":::::::ID---> "+doc.getId()+"File Path --->"+filepath);
totalAvailableFile++;
}
FileInputStream fileInputStreamReader = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStreamReader.read(bytes);
encodedfile = new String(Base64.getEncoder().encodeToString(bytes));
fileInputStreamReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
else
{
System.out.println("Else block");
PrintWriter out = new PrintWriter(new FileOutputStream(missing_files, true));
out.println("Available File Count --->"+missingFilecount+":::::::ID---> "+doc.getId()+"File Path --->"+filepath);
out.close();
missingFilecount++;
}
jsonMap = new HashMap<>();
jsonMap.put("id", doc.getId());
jsonMap.put("app_language", doc.getApp_language());
jsonMap.put("fileContent", encodedfile);
String id=Long.toString(doc.getId());
IndexRequest request = new IndexRequest(ATTACHMENT, "doc", id )
.source(jsonMap)
.setPipeline(ATTACHMENT);
PrintStream printStream = new PrintStream(new File("d:\\exception.txt"));
try {
IndexResponse response = SearchEngineClient.getInstance2().index(request);
} catch(ElasticsearchException e) {
if (e.status() == RestStatus.CONFLICT) {
}
e.printStackTrace(printStream);
}
totalFilePath++;
}
}
ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
clearScrollRequest.addScrollId(scrollId);
ClearScrollResponse clearScrollResponse = restHighLevelClient.clearScroll(clearScrollRequest);
boolean succeeded = clearScrollResponse.isSucceeded();
////part of Scroll API -- Ends
logger.info("Indexing done.....");
}
}
我使用的是 ES 6.2.3 版本
最佳答案
您收到该错误是因为您的搜索上下文在获取和处理所有结果之前已失效,因此为了解决此问题,您应该使搜索上下文保持更长时间的 Activity 。请引用Keeping the search context alive 。
增加滚动的时间值(value)。
new Scroll(TimeValue.timeValueMinutes(new_value));
将 new_value 增加到适合您的要求的值。
关于java - ElasticSearch JavaAPI (SearchScroll)-search_context_missing_exception","reason":"No search context found for id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51336462/
我正在编写一个节点应用程序,我想在其中混合 Reason 和原始 JavaScript。 This section在 bucklescript 文档中对其进行了描述 When user has an
为了将现有的基于 JS 的 WebUI 重构为 ReasonML,我试图嵌入一些重构的代码。目前,我通过将所有 ReasonML 代码(到目前为止)嵌入到 iframe 中来做到这一点。 . 空间非常
我正在尝试设置 RabbitMQ 以根据死亡原因通过死信交换路由消息(“x-death.reason”或“x-first-death-reason”都可以)。 我的理解是,当消息被发送到 DLX 时,
这是我的代码: public class FunctionalityCheckTest1 { InfModel infModel; Model model = ModelFactory
昨天我设法成功运行命令 expo build:ios 但今天早上它不起作用,我在输入凭据后收到以下错误消息: Trying to authenticate with Apple Developer P
我在 Klarna 预测试中得到了这个推理题。请帮我解决这个问题。 Question is in image 最佳答案 你是正确的 'B' 是答案1).中心 3 点,即第 3 列将保持不变2).第4列
在 JavaScript 中,你可以加入一个字符串数组,例如: fruits = ["orange", "apple", "banana"]; joined = fruits.join(", ");
当我使用“java -ea A”运行以下代码时,会触发断言更正,但我没有看到第二个参数。 public class A { public A() { assert 1==2,
我目前正在尝试原因并遇到我不理解的错误 这是我的代码: let mult = (x:float, y:float):float => x * y; 使用BuckleScript进行编译时,出现以下错误
发生了奇怪的事情。 当使用 url 调用以下 servlet 时:http://localhost:8080/Football/InsertTeam?p1_name=hkh&p2_name=klhjk
一些已经开始出现在我的代码中的东西是: {if (condition) { ; } else { ; }} ; 基本上我只想要 Child如果条件为真则渲染
首先我是自定义 TFS 的新手,我的 TFS 团队项目是 Microsoft Visual Studio Scrum 2013 的 99% vanilla 模板。所以我认为我的问题对某些人来说可能是显
我正在学习 reasonml 并且对此感到非常兴奋。我在 typescript react 代码中经常做的事情是: type Props = React.HTMLProps & { foo: bool
我在这里读过另一篇关于SO的文章,在可能的情况下,您不应该为标签生成成员(member)的。我想知道这可能是什么 DRAWBACKS ? 我说的好处是提高性能,对吗?还要别的吗? 我有一个带有100个
我试图使用 Int32 库编写一些代码,但我遇到了类型错误: let x : int = 7; Int32.abs(x) This has type: int But somewhere want
我是第一次探索 ReScript。我想使用记录类型作为我的键类型来构建 HashMap ,并且我正在寻找有关实现哈希函数的指导。 这是我的 ReScript 代码: type pointer = {
我想我是在问这个设计决定背后的基本原理。 数组可变的原因在默认情况下不可变的其他数据结构(列表、记录、散列图、集合)中显得异常突出。 这是有原因的吗?是否有不可变的替代方案? 最佳答案 确实没有“原因
在学习函数式编程时,我不断遇到“原因”这个术语,尤其是在纯函数和/或引用透明性的背景下。有人能解释一下这到底是什么意思吗? 最佳答案 通常,在编写程序时,您的工作不仅仅只是编写代码,您还想了解代码所展
考虑到以下人为的示例,是否可以编写一个可以处理具有 a 属性的任何记录的 get 函数? type type_one = {a: int} type type_two = {a: int, b: in
考虑到以下人为的示例,是否可以编写一个可以处理具有 a 属性的任何记录的 get 函数? type type_one = {a: int} type type_two = {a: int, b: in
我是一名优秀的程序员,十分优秀!