It exists multiple places you need to touch to add own analyzers into the Litium implementation.
Analyzers is used for both indexing and searching. You need to create a reference to Litium.Framework.Search.Lucene
NuGet package if it not already exists.
- Configure so implementation knows about your analyzer
Litium.Framework.Search.Lucene.AnalyzerService
.Instance
.Factory.Analyzers
.Add("my_analyzer", new global::Lucene.Net.Analysis.SimpleAnalyzer());
- Change how data is indexed
using System;
using System.Linq;
using Litium.Foundation.Modules.ProductCatalog.Search;
using Litium.Foundation.Search.Providers;
using Litium.Framework.Search.Indexing;
namespace Litium.Accelerator.Search
{
internal class AnalyzerProcessor : IIndexingProviderPreProcessor
{
public IndexDocument PreProcessDocument(IndexDocument document, string indexName)
{
if (ProductCatalogSearchDomains.Products.Equals(indexName, StringComparison.OrdinalIgnoreCase))
{
foreach (var tag in document.Tags.Where(x => x.Name.Equals("your_tag_name", StringComparison.OrdinalIgnoreCase)))
{
tag.Analyzed = true;
tag.Analyzer = "my_analyzer";
}
}
return document;
}
}
}
-
Searching
request.FilterTags.Add(new Tag("your_tag_name", "value") { Analyzer = "my_analyzer" });