As we know, at least in Lucene.NET 3.x.x version, the "stop words" are hand coded in this class "Lucene.Net.Analysis.StopAnalyzer". It does making the customizing the stop words a bit of tricky, especially for specific index since for the most of cases, you only need to customize one of the custom index to suit clients need. Here is a way how we can achieve that.
By default, Sitecore use "Lucene.Net.Analysis.Standard.StandardAnalyzer" and you can find it in wbe.config.(/configuration/sitecore/search/analyzer)
We create a new custom Analyzer inherit from "standardAnalyzer" and override the constructor. Here is the place I assign my own custom stop words to "STOP_WORDS_SET"
public class CustomAnalyzer : Lucene.Net.Analysis.Standard.StandardAnalyzer
{
private static ISet STOP_WORDS_SET = GetStopWords();//{{"by","by"}}; <-- Makes "by" a
public CustomAnalyzer()
: base(Lucene.Net.Util.Version.LUCENE_30, STOP_WORDS_SET)
{
}
private static ISet GetStopWords()
{
string[] strArray = GetWords();
CharArraySet set = new CharArraySet(strArray.Length, false);
set.AddAll((IEnumerable)strArray);
return (ISet)CharArraySet.UnmodifiableSet(set);
}
}
After, under "/configuration/sitecore/search/analyzer" in web.config, we wire the custom analyzer as below,
Lucene_30
Don't forget to register it from you custom index file
Done!!!