You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by vishal patel <vi...@outlook.com> on 2020/10/20 13:03:45 UTC

Add single or batch document in Solr 6.1.0

I am using solr 6.1.0. We have 2 shards and each has one replica.

I want to insert 100 documents in one collection. I am using below code.

org.apache.solr.client.solrj.impl.CloudSolrClient cloudServer = new org.apache.solr.client.solrj.impl.CloudSolrClient(zkHost);
cloudServer.setParallelUpdates(true);
cloudServer.setDefaultCollection(collection);

I have 2 ways to add the documents. single or batch
1) cloudServer.add(SolrInputDocument); //loop of 100 documents
2) cloudServer.add(List<SolrInputDocument>); // 100 documents

Note: we are not using cloudServer.commit from application. we used below configuration from solrconfig.xml
<autoCommit>
<maxTime>600000</maxTime>
       <maxDocs>20000</maxDocs>
       <openSearcher>false</openSearcher>
</autoCommit>
<autoSoftCommit>
       <maxTime>1000</maxTime>
</autoSoftCommit>
<maxWarmingSearchers>2</maxWarmingSearchers>

Which one is better for performance oriented single or batch? which one is faster for commit process?

Regards,
Vishal
<http://aka.ms/weboutlook>

Re: Add single or batch document in Solr 6.1.0

Posted by Erick Erickson <er...@gmail.com>.
Batching is better, see: https://lucidworks.com/post/really-batch-updates-solr-2/

> On Oct 20, 2020, at 9:03 AM, vishal patel <vi...@outlook.com> wrote:
> 
> I am using solr 6.1.0. We have 2 shards and each has one replica.
> 
> I want to insert 100 documents in one collection. I am using below code.
> 
> org.apache.solr.client.solrj.impl.CloudSolrClient cloudServer = new org.apache.solr.client.solrj.impl.CloudSolrClient(zkHost);
> cloudServer.setParallelUpdates(true);
> cloudServer.setDefaultCollection(collection);
> 
> I have 2 ways to add the documents. single or batch
> 1) cloudServer.add(SolrInputDocument); //loop of 100 documents
> 2) cloudServer.add(List<SolrInputDocument>); // 100 documents
> 
> Note: we are not using cloudServer.commit from application. we used below configuration from solrconfig.xml
> <autoCommit>
> <maxTime>600000</maxTime>
>       <maxDocs>20000</maxDocs>
>       <openSearcher>false</openSearcher>
> </autoCommit>
> <autoSoftCommit>
>       <maxTime>1000</maxTime>
> </autoSoftCommit>
> <maxWarmingSearchers>2</maxWarmingSearchers>
> 
> Which one is better for performance oriented single or batch? which one is faster for commit process?
> 
> Regards,
> Vishal
> <http://aka.ms/weboutlook>