Reputation: 5000
I'm currently working on improving the indexing speed of a application where I do not have full control of the code that performs the indexing. I have found out that the indexing code makes a commit after each document, something that I would like to avoid for performance reasons.
Question:
Is it possible in Solr to disable all commits made explicitly from a client and instead only rely on auto commits configured in the Solr config?
Upvotes: 2
Views: 1632
Reputation: 10544
As of Solr 5.3 (if not earlier) you can add the following to solrconfig.xml:
<updateRequestProcessorChain name="ignore-commit-from-client" default="true">
<processor class="solr.IgnoreCommitOptimizeUpdateProcessorFactory">
<int name="statusCode">200</int>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.DistributedUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
Upvotes: 1
Reputation: 60195
Smart question!
I've seen the same in a lot of applications, that's the first mistake everybody makes. It's not possible in Solr out of the box but something you can achieve writing your own UpdateRequestProcessor
I think.
As of now this is not possible to do in configuration but you could probably override the processCommit
method with an empty method, or just a log line. That should work fine unless the autocommit uses the same workflow, which shouldn't be the case but I would check. Anyway you can easily test this.
Once you've written your own component you have to make it available to solr as a jar and configure it in the update request processor chain (solrconfig.xml
):
<updateRequestProcessorChain>
<processor class="solr.NoCommitUpdateRequestProcessorFactory" />
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
Don't forget the last two lines which are the default request processors, otherwise all the update requests will do nothing!
Upvotes: 3