diff --git a/Px.Search.Lucene/LuceneSearcher.cs b/Px.Search.Lucene/LuceneSearcher.cs index 3a8a722e..28e55cae 100644 --- a/Px.Search.Lucene/LuceneSearcher.cs +++ b/Px.Search.Lucene/LuceneSearcher.cs @@ -7,7 +7,7 @@ namespace Px.Search.Lucene public class LuceneSearcher : ISearcher { private readonly IndexSearcher _indexSearcher; - private static readonly Operator _defaultOperator = Operator.AND; + private static readonly Operator _defaultOperator = Operator.OR; private readonly Analyzer _analyzer; private readonly string[] _fieldNames; diff --git a/PxWeb.UnitTests/Search/LuceneAnalyzerTest.cs b/PxWeb.UnitTests/Search/LuceneAnalyzerTest.cs index 49280de7..b8b54f6d 100644 --- a/PxWeb.UnitTests/Search/LuceneAnalyzerTest.cs +++ b/PxWeb.UnitTests/Search/LuceneAnalyzerTest.cs @@ -16,6 +16,14 @@ public void UsingSwedishAnalyzerOnSingular() TestSearcher("sv", "region", 3); } + [TestMethod] + public void SearchUsesOrAsDefaultOperator() + { + // "region" has 3 hits in current test data. + // The second term should not exist, so with OR the result should still be 3. + // With AND this would become 0, so this test guards the default operator behavior. + TestSearcher("sv", "region thistextdoesnotexist", 3); + } private void TestSearcher(string language, string searchFor, int expectedCount) { @@ -36,8 +44,6 @@ private void TestSearcher(string language, string searchFor, int expectedCount) MyHost myHost = new MyHost(wwwPath); - - var myOptions = Microsoft.Extensions.Options.Options.Create(luceneConfigurationOptions); ILuceneConfigurationService conf = new LuceneConfigurationService(myOptions, myHost);