Skip to content

Instantly share code, notes, and snippets.

Created June 13, 2017 18:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Viewing Sitecore search analyzer output
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Fr;
using Lucene.Net.Analysis.Tokenattributes;
using Sitecore.ContentSearch.LuceneProvider.Analyzers;
using System;
using System.IO;
namespace SitecoreAnalyzers
class Program
static void Main(string[] args)
var text = "Did the Quick Brown Fox jump over the Lazy Dog?";
var text_fr = "Le Fox brune rapide a-t-il sauté sur le chien paresseux?";
Console.WriteLine("** CaseSensitiveStandardAnalyzer **");
displayTokens(new CaseSensitiveStandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), text);
Console.WriteLine("** LowerCaseKeywordAnalyzer **");
displayTokens(new LowerCaseKeywordAnalyzer(), text);
Console.WriteLine("** NGramAnalyzer **");
displayTokens(new NGramAnalyzer(), text);
Console.WriteLine("** StandardAnalyzerWithStemming **");
displayTokens(new StandardAnalyzerWithStemming(Lucene.Net.Util.Version.LUCENE_30), text);
Console.WriteLine("** SynonymAnalyzer - see **");
displayTokens(new SynonymAnalyzer(new XmlSynonymEngine("synonyms.xml")), text);
Console.WriteLine("** FrenchAnalyzer **");
displayTokens(new FrenchAnalyzer(Lucene.Net.Util.Version.LUCENE_30), text_fr);
private static void displayTokens(Analyzer analyzer, string text)
var stream = analyzer.TokenStream("content", new StringReader(text));
var term = stream.AddAttribute<ITermAttribute>();
while (stream.IncrementToken())
Console.Write("'" + term.Term + "', ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment