Gravatar for dan@getfishtank.ca

Question by Dan Cruickshank, Sep 18, 2015 5:40 PM

Error when using Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex

Folks,

As we migrate over, we've ended up with a few Lucene indexes of type:

Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex

The indexes configurations have been swtiched over to:

configuration type="Coveo.SearchProvider.Configuration.CoveoSearchConfiguration, Coveo.SearchProvider"

When those index rebuilds are triggered via publish the following error occurs.

ManagedPoolThread #18 15:30:11 INFO  Job started: Index_Update_IndexName=rebrand_web
ManagedPoolThread #18 15:30:11 ERROR Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Jobs.Job.ThreadEntry(Object state)

Nested Exception

Exception: System.InvalidOperationException
Message: Index has not been initialized.
Source: Sitecore.ContentSearch.LuceneProvider
   at Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex.CreateFullRebuildContext()
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken)
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.Rebuild()

Normal "LuceneIndex" type indexes function as expected. I haven't decompiled the code to have a look. Any ideas of the fix?

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Sep 18, 2015 6:00 PM

Hi Dan,

I'm not sure of what you are trying to achieve here:

  1. Convert the Lucene index to a Coveo index
  2. Keep the Lucene index side by side with the other Coveo indexes

If you are trying to convert it, you're missing a few steps such as changing the type of the <index> element. If you are trying to run it side by side, I don't think you need to change the type of the <configuration> element. Take a look to the 2 documentation links.

Gravatar for dan@getfishtank.ca

Comment by Dan Cruickshank, Sep 18, 2015 6:06 PM

It's one step more involved. I can never get html/xml to show in the comments. :)

All have been converted. There are about 16 lucene indexes in the project, but a few have been switched from "Sitecore.ContentSearch.LuceneProvider.LuceneIndex" to "Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex" to ensure the highest availability.

Lucene's default behavior is to deletes an index in place before it rebuilds. But with that other index type, it essentially A-Bs the index. Builds a new index off to the side, makes it active, deletes the previous index.

Gravatar for dan@getfishtank.ca

Comment by Dan Cruickshank, Sep 18, 2015 6:09 PM

On publish, any index with "LuceneIndex" set as it's type work as expected. Any index set as "SwitchOnRebuildLuceneIndex" throws an error. They can still be rebuilt manually, but can no longer be triggered on a publish.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Sep 18, 2015 6:17 PM

Thanks for the explanation on different Lucene index types. Note that Coveo indexes are always available for queries while rebuilding them like the Lucene "SwitchOnRebuildLuceneIndex" indexes but with the difference that Coveo doesn't create a second index and switch at the end. It rebuilds over the existing index data, deleting documents that weren't rebuilt at the end of the rebuild.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Sep 18, 2015 6:18 PM

If you want to keep them managed by Lucene and you don't want to convert them to Coveo at all, why are you changing their <configuration> element type?

If you want to convert them to Coveo indexes, remove any reference to "SwitchOnRebuildLuceneIndex" in their configuration and use the Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider type.

Gravatar for dan@getfishtank.ca

Comment by Dan Cruickshank, Sep 18, 2015 11:40 PM

"If you want to keep them managed by Lucene and you don't want to convert them to Coveo at all, why are you changing their element type?"

Once we install Coveo, we have to change the configuration type on the Lucene indexes or they won't be recognized by Sitecore. This is large instance, many indexes. A lot of ContentSearch API and Lucene is very efficient.

Gravatar for dan@getfishtank.ca

Comment by Dan Cruickshank, Sep 18, 2015 11:42 PM

A lot of ContentSearch API and Lucene is very efficient. -> just meant that they won't be changed over.

So… am I sensing there isn't a fix for this other than changing everything to run as Coveo? :)

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Sep 20, 2015 7:41 PM

If you're on Sitecore 7.0 or 7.1, you must convert all the indexes to Coveo because Sitecore doesn't allow 2 different Search Providers at the same time.

If you're on Sitecore 7.2 to 7.5, Coveo for Sitecore is configured to only run his indexes by default but you can switch a flag to enable side by side indexes with other Search Providers as described in my second link.

If you're on Sitecore 8.0, Coveo for Sitecore is configured by default to run his indexes side by side with other Search Providers.

Gravatar for dan@getfishtank.ca

Comment by Dan Cruickshank, Sep 28, 2015 4:48 PM

So Jeff - turns out the underlying cause of the issue / confusion was a custom indexing strategy that threw a bit of a fit. Thanks again for your help.

Ask a question