Article For
5.3

Custom Analyzers


  • Analyzers are used by indexes to divide (tokenize) the indexed document fields into searchable tokens to allow a full-text search. Learn more at Creating Custom Analyzers.

  • Custom analyzers can be defined at either the database level, where they can only be used by indexes of that database, or at the server-wide level, where they can be used by all databases in the entire cluster.

  • If a database custom analyzer and a server-wide custom analyzer share the same name, the database custom analyzer will be the one used by the indexes of that database.

  • Once defined, the custom analyzer is added to the analyzer list, along with the Lucene analyzers that come with RavenDB out of the box. It can then be selected when configuring the index field options.

  • These views allow you to write your own custom analyzers:


Database Custom Analyzer View

Figure 1. Database Custom Analyzer View

Figure 1. Database Custom Analyzer View

1. Create a new database custom analyzer. Takes you to the analyzer editing view, see below.
2. Edit an existing analyzer.
3. Go to the Server-Wide Custom Analyzer View, see below.

1. Indicates that a database custom analyzer has the same name as a server-wide custom analyzer.
The database custom analyzer will be the one used by indexes of this database.

Server-Wide Custom Analyzer View

Figure 2. Server-Wide Custom Analyzer View

Figure 2. Server-Wide Custom Analyzer View

1. Create a new server-wide custom analyzer. Takes you to the analyzer editing view, see below.
2. Edit an existing analyzer.

Edit Custom Analyzer View

Figure 3. Edit Custom Analyzer View

Figure 3. Edit Custom Analyzer View

1. The name of your custom analyzer. This must be the same as the class name of your analyzer as it appears in your code. This cannot be changed afterwards.
2. The code of your analyzer. Must be compilable and include all necessary using statements. Learn more at Indexes: Analyzers.
3. Load an existing analyzer *.cs.
4. Save your analyzer.

Change the Default Analyzers

RavenDB has three default analyzers that it uses to index text when no other analyzer was specified:

  • Default Analyzer - LowerCaseKeywordAnalyzer
  • Default Exact Analyzer - KeywordAnalyzer
  • Default Search Analyzer - StandardAnalyzer

Read more here.

Figure 4. Database Settings View

Figure 4. Database Settings View

1. Navigate to Settings > Database Settings.
2. Click on Edit to modify the settings.

Here you can see the current values of the default analyzers:
1. Default Analyzer
2. Default Exact Analyzer
3. Default Search Analyzer

Figure 3. Edit Custom Analyzer View

Figure 3. Edit Custom Analyzer View

1. Select Indexing.
2. Click on Override to replace the default value.
3. Click on Save to modify the settings.