You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Plugins: Analyzer Generators

To add a custom analyzer, one must implement the AbstractAnalyzerGenerator class and provide logic when your custom analyzer should be used.

public abstract class AbstractAnalyzerGenerator
{
	public abstract Analyzer GenerateAnalyzerForIndexing(string indexName, Document document, Analyzer previousAnalyzer);

	public abstract Analyzer GenerateAnalyzerForQuerying(string indexName, string query, Analyzer previousAnalyzer);
}

where:
* GenerateAnalyzerForIndexing returns an analyzer that will be used while performing indexing operation.
* GenerateAnalyzerForQuerying returns an analyzer that will be used while performing querying.

Example - Using different analyzer for specific index

public class CustomAnalyzerGenerator : AbstractAnalyzerGenerator
{
	private const string SpecificIndexName = "Specific/Index";

	public override Analyzer GenerateAnalyzerForIndexing(string indexName, Document document, Analyzer previousAnalyzer)
	{
		if (indexName == SpecificIndexName)
		{
			return new WhitespaceAnalyzer();
		}

		return previousAnalyzer;
	}

	public override Analyzer GenerateAnalyzerForQuerying(string indexName, string query, Analyzer previousAnalyzer)
	{
		if (indexName == SpecificIndexName)
		{
			return new WhitespaceAnalyzer();
		}

		return previousAnalyzer;
	}
}