incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [06/50] [abbrv] git commit: Fixed BLUR-280
Date Wed, 13 Nov 2013 03:30:25 GMT
Fixed BLUR-280


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

Branch: refs/heads/blur-console-v2
Commit: e75fab65f12480cddcee4c240feb77789d45e711
Parents: 2e04778
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Oct 26 10:55:29 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Oct 26 10:57:21 2013 -0400

----------------------------------------------------------------------
 .../blur/lucene/search/BlurQueryParser.java     | 82 ++++++++++----------
 .../blur/lucene/search/SuperParserTest.java     |  8 ++
 2 files changed, 50 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e75fab65/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 2a04772..43601a2 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
@@ -45,18 +45,19 @@ public class BlurQueryParser extends QueryParser {
 
   @Override
   protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
-    String field = term.field();
+    String resolvedField = _fieldManager.resolveField(term.field());
     try {
-      Boolean b = _fieldManager.checkSupportForFuzzyQuery(field);
+      Boolean b = _fieldManager.checkSupportForFuzzyQuery(resolvedField);
       if (!(b == null || b)) {
-        throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
-            + "] which does not support fuzzy queries.");
+        throw new RuntimeException("Field [" + resolvedField + "] is type ["
+            + _fieldManager.getFieldTypeDefinition(resolvedField) + "] which does not support
fuzzy queries.");
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
-    customQueryCheck(field);
-    return addField(super.newFuzzyQuery(term, minimumSimilarity, prefixLength), term.field());
+    customQueryCheck(resolvedField);
+    return addField(super.newFuzzyQuery(new Term(resolvedField, term.text()), minimumSimilarity,
prefixLength),
+        resolvedField);
   }
 
   @Override
@@ -71,9 +72,9 @@ public class BlurQueryParser extends QueryParser {
       public void add(Term[] terms, int position) {
         super.add(terms, position);
         for (Term term : terms) {
-          String field = term.field();
-          customQueryCheck(field);
-          addField(this, field);
+          String resolvedField = _fieldManager.resolveField(term.field());
+          customQueryCheck(resolvedField);
+          addField(this, resolvedField);
         }
       }
     };
@@ -85,42 +86,43 @@ public class BlurQueryParser extends QueryParser {
       @Override
       public void add(Term term, int position) {
         super.add(term, position);
-        String field = term.field();
-        customQueryCheck(field);
-        addField(this, field);
+        String resolvedField = _fieldManager.resolveField(term.field());
+        customQueryCheck(resolvedField);
+        addField(this, resolvedField);
       }
     };
   }
 
   @Override
   protected Query newPrefixQuery(Term prefix) {
-    String field = prefix.field();
+    String resolvedField = _fieldManager.resolveField(prefix.field());
     try {
-      Boolean b = _fieldManager.checkSupportForPrefixQuery(field);
+      Boolean b = _fieldManager.checkSupportForPrefixQuery(resolvedField);
       if (!(b == null || b)) {
-        throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
-            + "] which does not support prefix queries.");
+        throw new RuntimeException("Field [" + resolvedField + "] is type ["
+            + _fieldManager.getFieldTypeDefinition(resolvedField) + "] which does not support
prefix queries.");
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
-    customQueryCheck(field);
-    return addField(super.newPrefixQuery(prefix), field);
+    customQueryCheck(resolvedField);
+    return addField(super.newPrefixQuery(new Term(resolvedField, prefix.text())), resolvedField);
   }
 
   @Override
   protected Query newRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    customQueryCheck(field);
+    String resolvedField = _fieldManager.resolveField(field);
+    customQueryCheck(resolvedField);
     Query q;
     try {
-      q = _fieldManager.getNewRangeQuery(field, part1, part2, startInclusive, endInclusive);
+      q = _fieldManager.getNewRangeQuery(resolvedField, part1, part2, startInclusive, endInclusive);
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
     if (q != null) {
-      return addField(q, field);
+      return addField(q, resolvedField);
     }
-    return addField(super.newRangeQuery(field, part1, part2, startInclusive, endInclusive),
field);
+    return addField(super.newRangeQuery(resolvedField, part1, part2, startInclusive, endInclusive),
resolvedField);
   }
 
   private void customQueryCheck(String field) {
@@ -137,26 +139,26 @@ public class BlurQueryParser extends QueryParser {
 
   @Override
   protected Query newTermQuery(Term term) {
-    String field = term.field();
+    String resolvedField = _fieldManager.resolveField(term.field());
     try {
-      Boolean b = _fieldManager.checkSupportForCustomQuery(field);
+      Boolean b = _fieldManager.checkSupportForCustomQuery(resolvedField);
       if (b != null && b) {
-        return _fieldManager.getCustomQuery(field, term.text());
+        return _fieldManager.getCustomQuery(resolvedField, term.text());
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
     Query q;
     try {
-      q = _fieldManager.getTermQueryIfNumeric(field, term.text());
+      q = _fieldManager.getTermQueryIfNumeric(resolvedField, term.text());
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
 
     if (q != null) {
-      return addField(q, field);
+      return addField(q, resolvedField);
     }
-    return addField(super.newTermQuery(term), field);
+    return addField(super.newTermQuery(new Term(resolvedField, term.text())), resolvedField);
   }
 
   @Override
@@ -164,34 +166,34 @@ public class BlurQueryParser extends QueryParser {
     if (SUPER.equals(t.field()) && "*".equals(t.text())) {
       return new MatchAllDocsQuery();
     }
-    String field = t.field();
+    String resolvedField = _fieldManager.resolveField(t.field());
     try {
-      Boolean b = _fieldManager.checkSupportForWildcardQuery(field);
+      Boolean b = _fieldManager.checkSupportForWildcardQuery(resolvedField);
       if (!(b == null || b)) {
-        throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
-            + "] which does not support wildcard queries.");
+        throw new RuntimeException("Field [" + resolvedField + "] is type ["
+            + _fieldManager.getFieldTypeDefinition(resolvedField) + "] which does not support
wildcard queries.");
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
-    customQueryCheck(field);
-    return addField(super.newWildcardQuery(t), t.field());
+    customQueryCheck(resolvedField);
+    return addField(super.newWildcardQuery(new Term(resolvedField, t.text())), resolvedField);
   }
 
   @Override
   protected Query newRegexpQuery(Term t) {
-    String field = t.field();
+    String resolvedField = _fieldManager.resolveField(t.field());
     try {
-      Boolean b = _fieldManager.checkSupportForRegexQuery(field);
+      Boolean b = _fieldManager.checkSupportForRegexQuery(resolvedField);
       if (!(b == null || b)) {
-        throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
-            + "] which does not support wildcard queries.");
+        throw new RuntimeException("Field [" + resolvedField + "] is type ["
+            + _fieldManager.getFieldTypeDefinition(resolvedField) + "] which does not support
wildcard queries.");
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
-    customQueryCheck(field);
-    return addField(super.newRegexpQuery(t), t.field());
+    customQueryCheck(resolvedField);
+    return addField(super.newRegexpQuery(new Term(resolvedField, t.text())), resolvedField);
   }
 
   private Query addField(Query q, String field) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e75fab65/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 253ea6f..6cc338d 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
@@ -89,6 +89,7 @@ public class SuperParserTest {
       }
     };
 
+    fieldManager.addColumnDefinition(null, "bin", null, false, "string", null);
     fieldManager.addColumnDefinitionInt("a", "id_i");
     fieldManager.addColumnDefinitionDouble("a", "id_d");
     fieldManager.addColumnDefinitionFloat("a", "id_f");
@@ -452,6 +453,13 @@ public class SuperParserTest {
     Query q1 = sq(tq("recordid", "123-456"));
     assertQuery(q1, q);
   }
+  
+  @Test
+  public void test37() throws ParseException {
+    Query q = parseSq("bin:cool");
+    Query q1 = sq(tq("_default_.bin", "cool"));
+    assertQuery(q1, q);
+  }
 
   public static BooleanClause bc_m(Query q) {
     return new BooleanClause(q, Occur.MUST);


Mime
View raw message