I'm using Lucene .Net 4.8 with the following Analyzer:
private static Analyzer CreateAnalyzer()
{
return Analyzer.NewAnonymous(createComponents: (fieldName, reader) =>
{
var source = new WhitespaceTokenizer(Lucene.Net.Util.LuceneVersion.LUCENE_48, reader);
TokenStream result = new WordDelimiterFilter(Lucene.Net.Util.LuceneVersion.LUCENE_48, source,
~WordDelimiterFlags.STEM_ENGLISH_POSSESSIVE,
CharArraySet.EMPTY_SET);
result = new LowerCaseFilter(Lucene.Net.Util.LuceneVersion.LUCENE_48, result);
return new TokenStreamComponents(source, result);
});
}
This works great for 95% of my use cases. For example, for the sentence "Hello MacDonald", all of the following will return a match: 'Hello', 'mac', 'dona".
My problem comes with emails like: "JoshSmith@microsoft.com"
Currently searching for 'Microsoft' or 'com' will return a match. But, since my WordDelimiterFilter stops at '.', searching for "microsoft.com" doesn't return a match.
Optimally, I'd like to index both "microsoft.com" and "com" so searching for both will return a match. I'm willing to settle for Lucene to treat dot '.' as a regular character and to index "microsoft.com" only.
I tried writing in the last parameter instead of "CharArraySet.EMPTY_SET" the following:
new CharArraySet(Lucene.Net.Util.LuceneVersion.LUCENE_48, new List<string>() { "." }, true)
Didn't help.
Can anyone help?