A new old client approached me. I hadn't worked for them in a decade, and I suspect their code base is twice as old as that. Don't we all love looking at old code?

The site was built with ColdFusion and used ColdFusion's underlying search engine to search files on their site. Ten years ago, the search engine in ColdFusion was Verity and we could index sites using the cfindex tag. However, over time Verity was replaced with Solr. This inadvertently caused some issues when re-indexing their site.

The Problem

Their code to index the site was like this:

view plain print about
1<cfindex action="update" collection="myCollection" type="file" key="someKey" urlPath="path" />

This was performed in a loop over all the new files in their site. Sometimes they did massive updates and the search indexing was failing.

The error was something like this:

Error opening new searcher.

Exceeded limit of maxWarmingSearchers=4, try again later

I set to work trying to fix it.

The Solution

If you search for this error you'll find a lot of information about the error and Solr; but none if it is particularly useful in the context of ColdFusion. The Solr engine is getting too many indexing requests and rejecting them. It took some experimentation, but I found a solution.

First, when you're indexing the site, add the autoCommit parameter to the tag and set it to false:

view plain print about
1<cfindex action="update" collection="myCollection" type="file" key="someKey" urlPath="path" autocommit="false" />

This tells Solr to add the files to the search collection, but not to index them yet. After all the files have been added, perform a commit action:

view plain print about
1<cfindex action="commit" collection="myCollection" />

Then all the files are indexed by the Solr engine at once. Discovering this was a bit tricky because the commit action is mentioned a few places in the documentation, but is not documented as a valid value for the action attribute of the cfindex tag.

After setting this up; everything worked great!