Does anyone have experience using a stemming analyzer with Lucene in Litium? Where would be the appropriate place to configure it?
Litium version: N/A
Does anyone have experience using a stemming analyzer with Lucene in Litium? Where would be the appropriate place to configure it?
Litium version: N/A
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.
Litium.Framework.Search.Lucene.AnalyzerService
.Instance
.Factory.Analyzers
.Add("my_analyzer", new global::Lucene.Net.Analysis.SimpleAnalyzer());
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;
}
}
}
request.FilterTags.Add(new Tag("your_tag_name", "value") { Analyzer = "my_analyzer" });
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.