You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Jorge Moreira <j....@gmail.com> on 2014/08/28 10:47:05 UTC

Indexing documents with ContentStreamUpdateRequest (SolrJ) asynchronously

I am using SolrJ API 4.8 to index rich documents to solr. But i want
to index these documents asynchronously. The function that I made send
documents synchronously but i don't know how to change it to make it
asynchronously. Any idea?

Function:

public Boolean indexDocument(HttpSolrServer server, String PathFile,
InputReader external)
{

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

        try {
                up.addFile(new File(PathFile), "text");
        } catch (IOException e) {

Logger.getLogger(ANOIndexer.class.getName()).log(Level.SEVERE, null,
e);
                return false;
        }

        up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

        try {
                server.request(up);
        } catch (SolrServerException e) {

Logger.getLogger(ANOIndexer.class.getName()).log(Level.SEVERE, null,
e);
                return false;

        } catch (IOException e) {

Logger.getLogger(ANOIndexer.class.getName()).log(Level.SEVERE, null,
e);
                return false;
        }
        return true;
}

Solr server: version 4.8.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org