Last active
December 19, 2016 11:46
-
-
Save NaibafCH/efd9e5599d938fa991fd5710678cc68e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Lucene.Net.Analysis; | |
using Lucene.Net.Analysis.NGram; | |
using Lucene.Net.Analysis.Standard; | |
using Lucene.Net.Util; | |
using Sitecore.Configuration; | |
namespace Sitecore.ContentSearch.LuceneProvider.Analyzers | |
{ | |
public class EdgeNgramAnalyzer : Lucene.Net.Analysis.Analyzer | |
{ | |
public override TokenStream TokenStream(string fieldName, TextReader reader) | |
{ | |
var defaultAnalyzer = new LowerCaseFilter(new StandardTokenizer(Version.LUCENE_30, reader)) as TokenStream; | |
var minLength = Settings.GetIntSetting("Sitecore.ContentSearch.Ngrams.MinLength", 3); | |
var maxLength = Settings.GetIntSetting("Sitecore.ContentSearch.Ngrams.MaxLength", 20); | |
var ngramsFront = new EdgeNGramTokenFilter(defaultAnalyzer, Side.FRONT, minLength, maxLength); | |
return new EdgeNGramTokenFilter(ngramsFront, Side.BACK, minLength, maxLength); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment