SolrJ addFile keeps documents open

試著忘記壹切 提交于 2019-12-13 03:37:27

问题


I've already submitted a similar question, but I've broken down the problem to its simplest form, so I'm gonna post it again:

The problem is, that SolrJ seems to keep file handles open, if I add the same file more than once.

I use the following method to submit a document to Solr:

public boolean addDocument( File doc ) throws IOException, SolrServerException {

    ContentStreamUpdateRequest csur = new ContentStreamUpdateRequest( "/update/extract" );

    csur.addFile( doc );
    csur.setParam( "literal.id", Utils.getAbsolutePath( doc ) );
    csur.setAction( AbstractUpdateRequest.ACTION.COMMIT, true, true );
    NamedList<Object> result = this.solr.request( csur );


    return result != null;
}

And this method to remove documents:

public void removeDocument( File doc ) throws IOException,
        SolrServerException {

    this.solr.deleteById( Utils.getAbsolutePath( doc ) );
    this.solr.commit();
}

But that seems to leave some File Handles lingering:

The following snippet demonstrates the problem:

File doc = new File( "../../testpdf/bbb.pdf" );
solr.addDocument( doc );
//solr.removeDocument( doc );   // Without these 2 lines, all handles
//solr.addDocument( doc );      // are released correctly

If I add the same document twice, SolrJ somehow keeps the handles alive, and the added document cannot be modified by any other processes.

I've already tried calling using csur.addContentStream() instead of csur.addFile() in addDocument and then closing the underlying Stream and Reader of the added stream, with no effect.

thx for any suggestions in advance


回答1:


Couldn't fix it, did a workaround by writing a custom ContentStream that buffers the document.



来源:https://stackoverflow.com/questions/4979244/solrj-keeps-indexed-files-open

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!