Lucene stemming

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.

  1. Configure so implementation knows about your analyzer
      .Add("my_analyzer", new global::Lucene.Net.Analysis.SimpleAnalyzer());
  1. 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;
  1. Searching
    request.FilterTags.Add(new Tag("your_tag_name", "value") { Analyzer = "my_analyzer" });
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.