Skip to content

solr.add(documentsIndexed) instead ? #3

@sebastienrichoz

Description

@sebastienrichoz

if(documentsIndexed.size() > NO_OF_DOCUMENT_TO_COMMIT) {
try {
solr.add(doSolrInputDocument);
solr.commit(true, true);
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Here you don't add the documentsIndexed but only the doSolrInputDocument to solr.
I would suggest something like this:

// Declare an atomic counter in the class
private AtomicInteger cnt = new AtomicInteger(0);

// Instead of the quoted lines do
try {
    solr.add(doSolrInputDocument);
    if (cnt.incrementAndGet() % NO_OF_DOCUMENT_TO_COMMIT == 0)
        solr.commit(true, true);
} catch (SolrServerException | IOException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions