incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [19/29] git commit: Fixing parsing issue with row query and system fields.
Date Fri, 31 Jul 2015 18:05:25 GMT
Fixing parsing issue with row query and system fields.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/9d5f1c30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/9d5f1c30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/9d5f1c30

Branch: refs/heads/blur-0.2.4-parcel
Commit: 9d5f1c304403355b7ee607e3a6e1387c9006bbf6
Parents: ab31c5f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Fri Jul 31 10:11:04 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Fri Jul 31 10:11:04 2015 -0400

----------------------------------------------------------------------
 .../blur/lucene/search/BlurQueryParser.java      |  5 +++--
 .../apache/blur/lucene/search/SuperParser.java   | 19 +++++++++++++++++--
 .../blur/lucene/search/SuperParserTest.java      |  7 +++++++
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9d5f1c30/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java b/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
index 58c8836..b611a19 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
@@ -170,9 +170,10 @@ public class BlurQueryParser extends QueryParser {
     if ("*".equals(t.text())) {
       String fieldName = t.field();
       if (SUPER.equals(fieldName)) {
-        return new MatchAllDocsQuery();
+        return addField(new MatchAllDocsQuery(), fieldName);
       } else {
-        return new TermQuery(new Term(BlurConstants.FIELDS, fieldName));
+        String resolvedField = _fieldManager.resolveField(t.field());
+        return addField(new TermQuery(new Term(BlurConstants.FIELDS, fieldName)), resolvedField);
       }
     }
     String resolvedField = _fieldManager.resolveField(t.field());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9d5f1c30/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
index 9858bf4..b2bc871 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
@@ -16,8 +16,17 @@
  */
 package org.apache.blur.lucene.search;
 
+import static org.apache.blur.utils.BlurConstants.FAMILY;
+import static org.apache.blur.utils.BlurConstants.FIELDS;
+import static org.apache.blur.utils.BlurConstants.PRIME_DOC;
+import static org.apache.blur.utils.BlurConstants.RECORD_ID;
+import static org.apache.blur.utils.BlurConstants.ROW_ID;
+
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.blur.analysis.FieldManager;
 import org.apache.blur.log.Log;
@@ -27,13 +36,13 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
 import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.FilteredQuery;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.util.Version;
 
 public class SuperParser extends BlurQueryParser {
@@ -45,6 +54,8 @@ public class SuperParser extends BlurQueryParser {
   }
 
   private static final String SEP = ".";
+  private static final Set<String> SYSTEM_FIELDS = new HashSet<String>(Arrays.asList(ROW_ID,
RECORD_ID, SUPER,
+      PRIME_DOC, FIELDS, FAMILY));
   private final boolean _superSearch;
   private final Filter _queryFilter;
   private final ScoreType _scoreType;
@@ -280,13 +291,17 @@ public class SuperParser extends BlurQueryParser {
     } else {
       String fieldName = _fieldNames.get(query);
       String currentGroupName = getGroupName(fieldName);
-      if (groupName.equals(currentGroupName)) {
+      if (groupName.equals(currentGroupName) || isSystemField(fieldName)) {
         return true;
       }
       return false;
     }
   }
 
+  private boolean isSystemField(String fieldName) {
+    return SYSTEM_FIELDS.contains(fieldName);
+  }
+
   private String getGroupName(String fieldName) {
     if (fieldName == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9d5f1c30/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
index 8d5c190..782d415 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
@@ -513,6 +513,13 @@ public class SuperParserTest {
     assertQuery(q1, q2);
   }
 
+  @Test
+  public void test44() throws ParseException {
+    Query q1 = parseSq("<f.c:abc recordid:123>");
+    Query q2 = sq(bq(bc(tq("f.c", "abc")), bc(new TermQuery(new Term("recordid", "123")))));
+    assertQuery(q1, q2);
+  }
+
   public static BooleanClause bc_m(Query q) {
     return new BooleanClause(q, Occur.MUST);
   }


Mime
View raw message