diff --git a/src/Examine.Test/Examine.Lucene/Search/AnalyzerTests.cs b/src/Examine.Test/Examine.Lucene/Search/AnalyzerTests.cs index 3d8665d17..9b5c8dd53 100644 --- a/src/Examine.Test/Examine.Lucene/Search/AnalyzerTests.cs +++ b/src/Examine.Test/Examine.Lucene/Search/AnalyzerTests.cs @@ -1,3 +1,6 @@ +using System; +using System.Linq; +using System.Text; using Examine.Lucene.Analyzers; using Examine.Lucene.Providers; using NUnit.Framework; @@ -18,7 +21,7 @@ public void Given_CultureInvariantWhitespaceAnalyzer_When_SearchingBothCharVaria ValueSet.FromObject(1.ToString(), "content", new { bodyText = "Something rød something"}), ValueSet.FromObject(2.ToString(), "content", - new { nodeName = "Something rod something"}) + new { bodyText = "Something rod something"}) }); var searcher = (BaseLuceneSearcher)indexer.Searcher; @@ -31,9 +34,13 @@ public void Given_CultureInvariantWhitespaceAnalyzer_When_SearchingBothCharVaria var query2 = searcher .CreateQuery("content") .Field("bodyText", "rød"); - var results2 = query1.Execute(); + var results2 = query2.Execute(); - Assert.AreEqual(1, results1.TotalItemCount); + Assert.AreEqual(2, results1.TotalItemCount); + DebugResults(results1); + + Assert.AreEqual(2, results2.TotalItemCount); + DebugResults(results2); } } @@ -48,7 +55,7 @@ public void Given_CultureInvariantStandardAnalyzer_When_SearchingBothCharVariant ValueSet.FromObject(1.ToString(), "content", new { bodyText = "Something rød something"}), ValueSet.FromObject(2.ToString(), "content", - new { nodeName = "Something rod something"}) + new { bodyText = "Something rod something"}) }); var searcher = (BaseLuceneSearcher)indexer.Searcher; @@ -61,9 +68,35 @@ public void Given_CultureInvariantStandardAnalyzer_When_SearchingBothCharVariant var query2 = searcher .CreateQuery("content") .Field("bodyText", "rød"); - var results2 = query1.Execute(); + var results2 = query2.Execute(); + + Assert.AreEqual(2, results1.TotalItemCount); + DebugResults(results1); - Assert.AreEqual(1, results1.TotalItemCount); + Assert.AreEqual(2, results2.TotalItemCount); + DebugResults(results2); + } + } + + private void DebugResults(ISearchResults results) + { + foreach(var r in results) + { + var sb = new StringBuilder(); + sb.Append("Id = "); + sb.Append(r.Id); + sb.Append(", Values = "); + foreach(var vals in r.AllValues) + { + sb.Append(vals.Key); + sb.Append(" = "); + foreach(var val in vals.Value) + { + sb.Append(val); + sb.Append(", "); + } + } + Console.WriteLine(sb.ToString()); } } }