lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [18/58] lucenenet git commit: QueryParser.Flexible Refactor: Nested Operator enum within StandardQueryConfigHandler
Date Tue, 06 Dec 2016 15:11:53 GMT
QueryParser.Flexible Refactor: Nested Operator enum within StandardQueryConfigHandler


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/67cd4482
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/67cd4482
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/67cd4482

Branch: refs/heads/master
Commit: 67cd44821161b042cb768a98cefe236cc44ae6bd
Parents: 0aa30ca
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Nov 29 22:48:39 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Nov 29 22:48:39 2016 +0700

----------------------------------------------------------------------
 .../BooleanModifiersQueryNodeProcessor.cs         |  3 ++-
 .../Standard/Config/StandardQueryConfigHandler.cs | 18 +++++++++---------
 .../Processors/AnalyzerQueryNodeProcessor.cs      | 10 +++++-----
 .../BooleanQuery2ModifierNodeProcessor.cs         |  1 +
 .../Processors/GroupQueryNodeProcessor.cs         |  1 +
 .../Flexible/Standard/StandardQueryParser.cs      |  1 +
 .../Precedence/TestPrecedenceQueryParser.cs       | 16 ++++++++--------
 .../Standard/TestMultiAnalyzerQPHelper.cs         |  2 +-
 .../Flexible/Standard/TestMultiFieldQPHelper.cs   |  4 ++--
 .../Flexible/Standard/TestQPHelper.cs             |  6 +++---
 .../Flexible/Standard/TestStandardQP.cs           | 18 +++++++++---------
 11 files changed, 42 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
index 02fd07b..a08a580 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Precedence.Processors
 {
@@ -67,7 +68,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Precedence.Processors
 
             }
             else if (this.usingAnd && node is BooleanQueryNode
-              && !(node is OrQueryNode))
+                && !(node is OrQueryNode))
             {
 
                 this.childrenBuffer.Clear();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Standard/Config/StandardQueryConfigHandler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Config/StandardQueryConfigHandler.cs
b/src/Lucene.Net.QueryParser/Flexible/Standard/Config/StandardQueryConfigHandler.cs
index a3e10af..ddfad70 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Standard/Config/StandardQueryConfigHandler.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Config/StandardQueryConfigHandler.cs
@@ -45,6 +45,15 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Config
             Set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<string, DateTools.Resolution?>());
 
         }
+
+        /**
+        * Boolean Operator: AND or OR
+        */
+        public enum Operator
+        {
+            AND,
+            OR
+        }
     }
 
     /**
@@ -188,13 +197,4 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Config
         public readonly static ConfigurationKey<IDictionary<string, NumericConfig>>
NUMERIC_CONFIG_MAP = ConfigurationKey.NewInstance<IDictionary<string, NumericConfig>>();
 
     }
-
-    /**
-     * Boolean Operator: AND or OR
-     */
-    public enum Operator
-    {
-        AND,
-        OR
-    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/AnalyzerQueryNodeProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/AnalyzerQueryNodeProcessor.cs
b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/AnalyzerQueryNodeProcessor.cs
index 2e050ed..bbfccea 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/AnalyzerQueryNodeProcessor.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/AnalyzerQueryNodeProcessor.cs
@@ -13,7 +13,7 @@ using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using static Lucene.Net.QueryParsers.Classic.QueryParserBase;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
 {
@@ -44,7 +44,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
 
         private bool positionIncrementsEnabled;
 
-        private Config.Operator defaultOperator;
+        private Operator defaultOperator;
 
         public AnalyzerQueryNodeProcessor()
         {
@@ -62,7 +62,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
                 this.positionIncrementsEnabled = false;
                 bool? positionIncrementsEnabled = GetQueryConfigHandler().Get(ConfigurationKeys.ENABLE_POSITION_INCREMENTS);
                 var defaultOperator = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);
-                this.defaultOperator = defaultOperator != null ? defaultOperator.Value :
Config.Operator.OR;
+                this.defaultOperator = defaultOperator != null ? defaultOperator.Value :
Operator.OR;
 
                 if (positionIncrementsEnabled != null)
                 {
@@ -249,7 +249,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
                                 {
                                     if (currentQuery != null)
                                     {
-                                        if (this.defaultOperator == Config.Operator.OR)
+                                        if (this.defaultOperator == Operator.OR)
                                         {
                                             q.Add(currentQuery);
                                         }
@@ -261,7 +261,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
                                     currentQuery = new FieldQueryNode(field, term, -1, -1);
                                 }
                             }
-                            if (this.defaultOperator == Config.Operator.OR)
+                            if (this.defaultOperator == Operator.OR)
                             {
                                 q.Add(currentQuery);
                             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/BooleanQuery2ModifierNodeProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/BooleanQuery2ModifierNodeProcessor.cs
b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/BooleanQuery2ModifierNodeProcessor.cs
index 6c5ed50..e6d392f 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/BooleanQuery2ModifierNodeProcessor.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/BooleanQuery2ModifierNodeProcessor.cs
@@ -8,6 +8,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/GroupQueryNodeProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/GroupQueryNodeProcessor.cs
b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/GroupQueryNodeProcessor.cs
index d99c5b7..dcc6f44 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/GroupQueryNodeProcessor.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/GroupQueryNodeProcessor.cs
@@ -8,6 +8,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.QueryParser/Flexible/Standard/StandardQueryParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/StandardQueryParser.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/StandardQueryParser.cs
index 9819378..498ea99 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Standard/StandardQueryParser.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/StandardQueryParser.cs
@@ -13,6 +13,7 @@ using System.Globalization;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Standard
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.Tests.QueryParser/Flexible/Precedence/TestPrecedenceQueryParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Precedence/TestPrecedenceQueryParser.cs
b/src/Lucene.Net.Tests.QueryParser/Flexible/Precedence/TestPrecedenceQueryParser.cs
index 4c48617..6a3db29 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Precedence/TestPrecedenceQueryParser.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Precedence/TestPrecedenceQueryParser.cs
@@ -129,7 +129,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Precedence
                 a = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
             PrecedenceQueryParser qp = new PrecedenceQueryParser();
             qp.Analyzer = (a);
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.OR); // LUCENENET
TODO: Change API back to the way it was..?
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.OR); // LUCENENET TODO:
Change API back to the way it was..?
             return qp;
         }
 
@@ -181,7 +181,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Precedence
                 a = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
             PrecedenceQueryParser qp = new PrecedenceQueryParser();
             qp.Analyzer = (a);
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             return qp.Parse(query, "field");
         }
 
@@ -244,11 +244,11 @@ namespace Lucene.Net.QueryParsers.Flexible.Precedence
             PrecedenceQueryParser qp = new PrecedenceQueryParser();
             qp.Analyzer = (new MockAnalyzer(Random()));
             // make sure OR is the default:
-            assertEquals(/*StandardQueryConfigHandler.*/Operator.OR, qp.DefaultOperator);
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/ Operator.AND);
-            assertEquals(/*StandardQueryConfigHandler.*/ Operator.AND, qp.DefaultOperator);
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/ Operator.OR);
-            assertEquals(/*StandardQueryConfigHandler.*/ Operator.OR, qp.DefaultOperator);
+            assertEquals(StandardQueryConfigHandler.Operator.OR, qp.DefaultOperator);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
+            assertEquals(StandardQueryConfigHandler.Operator.AND, qp.DefaultOperator);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.OR);
+            assertEquals(StandardQueryConfigHandler.Operator.OR, qp.DefaultOperator);
 
             assertQueryEquals("a OR !b", null, "a -b");
             assertQueryEquals("a OR ! b", null, "a -b");
@@ -694,7 +694,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Precedence
             query2 = parser.Parse("A (-B +C)", "field");
             assertEquals(query1, query2);
 
-            parser.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            parser.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             query1 = parser.Parse("A AND B OR C AND D", "field");
             query2 = parser.Parse("(A AND B) OR (C AND D)", "field");
             assertEquals(query1, query2);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiAnalyzerQPHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiAnalyzerQPHelper.cs
b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiAnalyzerQPHelper.cs
index 850e52b..b5ab71c 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiAnalyzerQPHelper.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiAnalyzerQPHelper.cs
@@ -85,7 +85,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
             qp.SetDefaultPhraseSlop(0);
 
             // non-default operator:
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             assertEquals("+(multi multi2) +foo", qp.Parse("multi foo", "").toString());
 
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs
b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs
index e62d5bc..351be88 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs
@@ -118,7 +118,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
             assertEquals("(b:one t:one) f:two", q.toString());
 
             // AND mode:
-            mfqp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            mfqp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             q = mfqp.Parse("one two", null);
             assertEquals("+(b:one t:one) +(b:two t:two)", q.toString());
             q = mfqp.Parse("\"aa bb cc\" \"dd ee\"", null);
@@ -361,7 +361,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
 
             mfqp.SetMultiFields(new String[] { "body" });
             mfqp.Analyzer = (analyzer);
-            mfqp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            mfqp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             Query q = mfqp.Parse("the footest", null);
             IndexReader ir = DirectoryReader.Open(ramDir);
             IndexSearcher @is = NewSearcher(ir);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestQPHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestQPHelper.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestQPHelper.cs
index 849f826..b1cae18 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestQPHelper.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestQPHelper.cs
@@ -184,7 +184,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
             StandardQueryParser qp = new StandardQueryParser();
             qp.Analyzer = (a);
 
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.OR);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.OR);
 
             return qp;
 
@@ -286,7 +286,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
                 a = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
             StandardQueryParser qp = new StandardQueryParser();
             qp.Analyzer = (a);
-            qp.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            qp.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
 
             return qp.Parse(query, "field");
 
@@ -1424,7 +1424,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
 
             StandardQueryParser parser = new StandardQueryParser();
             parser.SetMultiFields(fields);
-            parser.DefaultOperator = (/*StandardQueryConfigHandler.*/Operator.AND);
+            parser.DefaultOperator = (StandardQueryConfigHandler.Operator.AND);
             parser.Analyzer = (new MockAnalyzer(Random()));
 
             BooleanQuery exp = new BooleanQuery();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/67cd4482/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestStandardQP.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestStandardQP.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestStandardQP.cs
index fd61069..61de93d 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestStandardQP.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestStandardQP.cs
@@ -10,12 +10,12 @@ using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using static Lucene.Net.Documents.DateTools;
-using static Lucene.Net.QueryParsers.Classic.QueryParserBase;
+using Lucene.Net.Documents;
 using System.IO;
 using Lucene.Net.Index;
 using Lucene.Net.QueryParsers.Flexible.Standard.Config;
 using NUnit.Framework;
+using Operator = Lucene.Net.QueryParsers.Flexible.Standard.Config.StandardQueryConfigHandler.Operator;
 
 namespace Lucene.Net.QueryParsers.Flexible.Standard
 {
@@ -28,7 +28,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
         {
             if (a == null) a = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
             StandardQueryParser qp = new StandardQueryParser(a);
-            qp.DefaultOperator = (Config.Operator.OR);
+            qp.DefaultOperator = (Operator.OR);
 
             return qp;
         }
@@ -70,7 +70,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
         {
             Debug.Assert(cqpC is StandardQueryParser);
             StandardQueryParser qp = (StandardQueryParser)cqpC;
-            qp.DefaultOperator = (Config.Operator.OR);
+            qp.DefaultOperator = (Operator.OR);
         }
 
 
@@ -78,7 +78,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
         {
             Debug.Assert(cqpC is StandardQueryParser);
             StandardQueryParser qp = (StandardQueryParser)cqpC;
-            qp.DefaultOperator = (Config.Operator.AND);
+            qp.DefaultOperator = (Operator.AND);
         }
 
 
@@ -97,7 +97,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
 
 
         public override void SetDateResolution(ICommonQueryParserConfiguration cqpC,
-            string field, Resolution value)
+            string field, DateTools.Resolution value)
         {
             Debug.Assert(cqpC is StandardQueryParser);
             StandardQueryParser qp = (StandardQueryParser)cqpC;
@@ -203,11 +203,11 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
         {
             StandardQueryParser qp = GetParser(new MockAnalyzer(Random()));
             // make sure OR is the default:
-            assertEquals(/*StandardQueryConfigHandler.*/Config.Operator.OR, qp.DefaultOperator);
+            assertEquals(StandardQueryConfigHandler.Operator.OR, qp.DefaultOperator);
             SetDefaultOperatorAND(qp);
-            assertEquals(/*StandardQueryConfigHandler.*/Config.Operator.AND, qp.DefaultOperator);
+            assertEquals(StandardQueryConfigHandler.Operator.AND, qp.DefaultOperator);
             SetDefaultOperatorOR(qp);
-            assertEquals(/*StandardQueryConfigHandler.*/Config.Operator.OR, qp.DefaultOperator);
+            assertEquals(StandardQueryConfigHandler.Operator.OR, qp.DefaultOperator);
         }
 
 


Mime
View raw message