在崩溃的情况下没有保存结果

时间:2018-06-11 07:09:36

标签: java python-3.x lucene

我使用Spring设置了一个服务器,该服务器接受带有JSON文件的POST请求。然后将此JSON转换为Lucene Document并编制索引。

通常,当JSON到达时,如果此类文档已被索引,则首先使用哈希检查它。如果是,则忽略它。

有时,应用程序因致命错误(SIGSEGV)而崩溃。我希望只有最后一个POST中的JSON无法保存。但是,JSON之前的 ALL (在当前Python运行中的所有前面的POST请求中)都无法保存。我尝试在每次处理完POST后使用<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" > <ul class="nav d-flex justify-content-between"> <li class="nav-item"> <a class="nav-link active" href="#">Link 1</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link 2</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link 3</a> </li> </ul>flush(),但无济于事。

如果我决定只发送commit() POST请求,并且所有结束都没有错误,那么它们将成功保存,以备将来的所有Python运行。

请求按顺序发送。

N

发送JSON请求的Python脚本:

private void index(List<Document> documents) throws CustomException {
  try {
    IndexWriter writer = getWriter();
    for (Document document : documents) {
      writer.updateDocument(new Term(document.get(FIELD_ID)), document);
    }

    writer.flush();
    writer.commit();
  } catch (IOException ioe) {
    throw new CustomException("Failed to open or write into the index.");
  }
}

0 个答案:

没有答案
相关问题