문제

i (웹) 응용 프로그램에서 다음 워크 플로우가 있습니다.

  • 아카이브에서 PDF 파일 다운로드
  • 파일
  • 파일 삭제

내 문제는 파일을 인덱싱 한 후 잠긴 상태로 유지되고 삭제 파트가 예외가 발생합니다.

여기서 파일을 인덱싱하기위한 코드 스 니펫입니다.

try
{
   ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
   req.addFile(file, type);
   req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

   NamedList<Object> result = server.request(req);

   Assert.assertEquals(0, ((NamedList<?>) result.get("responseHeader")).get("status"));
}
.

뭔가를 그리워합니까?

편집 :

나는이 방법을 시도했지만 동일한 결과를 가지고 ...

ContentStream contentStream = null;

    try
    {
      contentStream = new ContentStreamBase.FileStream(document);

      ContentStreamUpdateRequest req = new ContentStreamUpdateRequest(UPDATE_EXTRACT_REQUEST);
//      req.addFile(document, context.getProperty(FTSConstants.CONTENT_TYPE_APPLICATION_PDF));
      req.addContentStream(contentStream);
      req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

      NamedList<Object> result = server.request(req);

      if (!((NamedList<?>) result.get("responseHeader")).get("status").equals(0))
      {
        throw new IDSystemException(LOG, "Document could not be indexed. Status returned: " +
                                         ((NamedList<?>) result.get("responseHeader")).get("status"));
      }
    }
    catch (FileNotFoundException fnfe)
    {
      throw new IDSystemException(LOG, fnfe.getMessage(), fnfe);
    }
    catch (IOException ioe)
    {
      throw new IDSystemException(LOG, ioe.getMessage(), ioe);
    }
    catch (SolrServerException sse)
    {
      throw new IDSystemException(LOG, sse.getMessage(), sse);
    }
    finally
    {
      try
      {
        if(contentStream != null && contentStream.getStream() != null)
        {
          contentStream.getStream().close();
        }
      }
      catch (IOException ioe)
      {
        throw new IDSystemException(LOG, ioe.getMessage(), ioe);
      }
    }
.

도움이 되었습니까?

해결책

이것은 버그처럼 보입니다.

패치가 여기에 제안되었습니다 https://issues.apache.org/jira/browse/solr-1744

체크 아웃 "Nofollow"> http : //lucene.472066.n3..Nabble.com / ContentStreamUpdateRequest-addfile-fails-home-close-td485429.html

스트림이 null이 아닌지 확인하고 닫습니다.

다른 팁

파일 시스템에서 획득 한 잠금 때문일 수 있습니다.AddFile () 대신 다음을 시도 할 수 있습니다.

ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
ContentStreamBase.FileStream fileStream = new FileStream(file);
req.addContentStream(fileStream);
.

shishir

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top