开发者

SolrJ addFile keeps documents open

开发者 https://www.devze.com 2023-02-10 00:54 出处:网络
I\'ve already submitted a similar question, b开发者_运维技巧ut I\'ve broken down the problem to its simplest form, so I\'m gonna post it again:

I've already submitted a similar question, b开发者_运维技巧ut 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号