Search code examples
c#ravendb

RavenDB specify Lucene vs Corax in C# code


I'm migrating from RavenDB 6.0.106 to 6.2.

I have a lot of complex indexes that are not compatible with Corax. Using the UI, one can set which index type is used.

However, after perusing the RavenDB site, I have yet to find how to specify this in C# code alone. Is this even possible? If so, how is it done? Where's the documentation?


Solution

  • You can specify which search engine to use in 3 ways/levels:

    1. Setting the search engine server-wide (for all databases):
      update your settings.json file as shown in this link:
      https://ravendb.net/docs/article-page/6.2/csharp/indexes/search-engine/corax#select-search-engine-server-wide
    2. Setting the search engine per database:
      done via the Studio as shown in this link:
      https://ravendb.net/docs/article-page/6.2/csharp/indexes/search-engine/corax#select-search-engine-per-database
    3. Setting the search engine per index:
      can be done via the client API code as shown in this link:
      https://ravendb.net/docs/article-page/6.2/csharp/indexes/search-engine/corax#select-index-search-engine-using-code
      For example, set this in your index definition:
      SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Corax;
      Or
      SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Lucene;