incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: Adding some more checks to the query parser.
Date Mon, 17 Jun 2013 19:38:04 GMT
Adding some more checks to the query parser.


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

Branch: refs/heads/master
Commit: fd208badc5a9d34490c983d2240581f71741c330
Parents: 77262a9
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Jun 17 15:37:35 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Jun 17 15:37:35 2013 -0400

----------------------------------------------------------------------
 .../blur/lucene/search/BlurQueryParser.java     | 135 +++++++++++
 .../apache/blur/lucene/search/SuperParser.java  | 242 ++++++-------------
 .../blur/lucene/search/SuperParserTest.java     |  58 +++--
 3 files changed, 232 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fd208bad/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
new file mode 100644
index 0000000..5e5022f
--- /dev/null
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
@@ -0,0 +1,135 @@
+package org.apache.blur.lucene.search;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.blur.analysis.BlurAnalyzer;
+import org.apache.blur.analysis.BlurAnalyzer.TYPE;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MultiPhraseQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
+
+public class BlurQueryParser extends QueryParser {
+
+  public static final String SUPER = "super";
+
+  protected final Map<Query, String> _fieldNames;
+  protected final BlurAnalyzer _blurAnalyzer;
+
+  public BlurQueryParser(Version matchVersion, String f, BlurAnalyzer a, Map<Query, String>
fieldNames) {
+    super(matchVersion, f, a);
+    _blurAnalyzer = a;
+    _fieldNames = fieldNames == null ? new HashMap<Query, String>() : fieldNames;
+  }
+
+  @Override
+  protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
+    String field = term.field();
+    TYPE type = _blurAnalyzer.getTypeLookup(field);
+    if (type != TYPE.TEXT) {
+      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support fuzzy queries.");
+    }
+    return addField(super.newFuzzyQuery(term, minimumSimilarity, prefixLength), term.field());
+  }
+
+  @Override
+  protected Query newMatchAllDocsQuery() {
+    return addField(super.newMatchAllDocsQuery(), UUID.randomUUID().toString());
+  }
+
+  @Override
+  protected MultiPhraseQuery newMultiPhraseQuery() {
+    return new MultiPhraseQuery() {
+
+      @Override
+      public void add(Term[] terms, int position) {
+        super.add(terms, position);
+        for (Term term : terms) {
+          addField(this, term.field());
+        }
+      }
+    };
+  }
+
+  @Override
+  protected PhraseQuery newPhraseQuery() {
+    return new PhraseQuery() {
+
+      @Override
+      public void add(Term term, int position) {
+        super.add(term, position);
+        addField(this, term.field());
+      }
+    };
+  }
+
+  @Override
+  protected Query newPrefixQuery(Term prefix) {
+    String field = prefix.field();
+    TYPE type = _blurAnalyzer.getTypeLookup(field);
+    if (type != TYPE.TEXT) {
+      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support prefix queries.");
+    }
+    return addField(super.newPrefixQuery(prefix), field);
+  }
+
+  @Override
+  protected Query newRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
+    Query q = _blurAnalyzer.getNewRangeQuery(field, part1, part2, startInclusive, endInclusive);
+    if (q != null) {
+      return addField(q, field);
+    }
+    return addField(super.newRangeQuery(field, part1, part2, startInclusive, endInclusive),
field);
+  }
+
+  @Override
+  protected Query newTermQuery(Term term) {
+    String field = term.field();
+    Query q = _blurAnalyzer.getNewRangeQuery(field, term.text(), term.text(), true, true);
+    if (q != null) {
+      return addField(q, field);
+    }
+    return addField(super.newTermQuery(term), field);
+  }
+
+  @Override
+  protected Query newWildcardQuery(Term t) {
+    if (SUPER.equals(t.field()) && "*".equals(t.text())) {
+      return new MatchAllDocsQuery();
+    }
+    String field = t.field();
+    TYPE type = _blurAnalyzer.getTypeLookup(field);
+    if (type != TYPE.TEXT) {
+      throw new RuntimeException("Field [" + field + "] is type [" + type
+          + "] which does not support wildcard queries.");
+    }
+    return addField(super.newWildcardQuery(t), t.field());
+  }
+
+  private Query addField(Query q, String field) {
+    _fieldNames.put(q, field);
+    return q;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fd208bad/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 9c5a323..77622af 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
@@ -17,15 +17,11 @@ package org.apache.blur.lucene.search;
  * limitations under the License.
  */
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.blur.analysis.BlurAnalyzer;
-import org.apache.blur.analysis.BlurAnalyzer.TYPE;
 import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.ParseException;
@@ -35,43 +31,30 @@ 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.MultiPhraseQuery;
-import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.util.Version;
 
-public class SuperParser extends QueryParser {
+public class SuperParser extends BlurQueryParser {
 
   private static final String MUST_NOT_STRING = "-";
   private static final String MUST_STRING = "+";
   private static final Pattern PATTERN = Pattern.compile("([-+]{0,1})\\s*?super\\s*?\\:\\s*?\\<(.*?)\\>");
   private static final Pattern CHECK = Pattern.compile("super\\s*?\\:\\s*?\\<");
-  private static final String SUPER = "super";
-  private final Map<Query, String> _fieldNames = new HashMap<Query, String>();
+  private static final String SEP = ".";
   private final boolean _superSearch;
   private final Filter _queryFilter;
   private final ScoreType _scoreType;
-  private final BlurAnalyzer _blurAnalyzer;
   private final Version _matchVersion;
   private final Term _defaultPrimeDocTerm;
-  private final boolean _autoGrouping;
 
   public SuperParser(Version matchVersion, BlurAnalyzer a, boolean superSearch, Filter queryFilter,
       ScoreType scoreType, Term defaultPrimeDocTerm) {
-    this(matchVersion, a, superSearch, queryFilter, scoreType, defaultPrimeDocTerm, false);
-  }
-
-  public SuperParser(Version matchVersion, BlurAnalyzer a, boolean superSearch, Filter queryFilter,
-      ScoreType scoreType, Term defaultPrimeDocTerm, boolean autoGrouping) {
-    super(matchVersion, "super", a);
+    super(matchVersion, SUPER, a, null);
     _matchVersion = matchVersion;
     _superSearch = superSearch;
     _queryFilter = queryFilter;
     _scoreType = scoreType;
-    _blurAnalyzer = a;
     _defaultPrimeDocTerm = defaultPrimeDocTerm;
-    _autoGrouping = autoGrouping;
     setAutoGeneratePhraseQueries(true);
     setAllowLeadingWildcard(true);
   }
@@ -103,16 +86,28 @@ public class SuperParser extends QueryParser {
         }
         Occur occur = getOccur(occurString);
         QueryParser parser = getNewParser();
-        Query superQuery = parser.parse(superQueryStr);
-        booleanQuery.add(new SuperQuery(superQuery, _scoreType, _defaultPrimeDocTerm), occur);
+        Query subQuery = parser.parse(superQueryStr);
+        if (!isSameGroupName(subQuery)) {
+          throw new ParseException("Super query [" + occurString + superQueryStr
+              + "] cannot reference more than one column family.");
+        }
+        booleanQuery.add(newSuperQuery(subQuery), occur);
         lastEnd = end;
       }
     }
     booleanQuery = addExtraQueryInfo(query, booleanQuery, lastEnd);
-    if (booleanQuery == null) {
-      return reprocess(super.parse(query));
+    Query result = booleanQuery;
+    if (result == null) {
+      result = reprocess(super.parse(query));
     }
-    return booleanQuery;
+    return result;
+  }
+
+  private boolean isSameGroupName(Query query) {
+    if (query instanceof BooleanQuery) {
+      return isSameGroupName((BooleanQuery) query);
+    }
+    return true;
   }
 
   private BooleanQuery addExtraQueryInfo(String query, BooleanQuery booleanQuery, int lastEnd,
int start, int end)
@@ -151,17 +146,16 @@ public class SuperParser extends QueryParser {
     if (subQuery instanceof BooleanQuery) {
       BooleanQuery bq = (BooleanQuery) subQuery;
       for (BooleanClause clause : bq) {
-        booleanQuery.add(new SuperQuery(clause.getQuery(), _scoreType, _defaultPrimeDocTerm),
clause.getOccur());
+        booleanQuery.add(newSuperQuery(clause.getQuery()), clause.getOccur());
       }
     } else {
-      booleanQuery.add(new SuperQuery(subQuery, _scoreType, _defaultPrimeDocTerm), Occur.SHOULD);
+      booleanQuery.add(newSuperQuery(subQuery), Occur.SHOULD);
     }
     return booleanQuery;
   }
 
   private QueryParser getNewParser() {
-    QueryParser parser = new QueryParser(_matchVersion, SUPER, _blurAnalyzer);
-    return parser;
+    return new BlurQueryParser(_matchVersion, SUPER, _blurAnalyzer,_fieldNames);
   }
 
   private Occur getOccur(String occurString) {
@@ -174,152 +168,71 @@ public class SuperParser extends QueryParser {
     return Occur.SHOULD;
   }
 
-  @Override
-  protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
-    String field = term.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support fuzzy queries.");
-    }
-    return addField(super.newFuzzyQuery(term, minimumSimilarity, prefixLength), term.field());
-  }
-
-  @Override
-  protected Query newMatchAllDocsQuery() {
-    return addField(super.newMatchAllDocsQuery(), UUID.randomUUID().toString());
-  }
-
-  @Override
-  protected MultiPhraseQuery newMultiPhraseQuery() {
-    return new MultiPhraseQuery() {
-
-      @Override
-      public void add(Term[] terms, int position) {
-        super.add(terms, position);
-        for (Term term : terms) {
-          addField(this, term.field());
-        }
-      }
-    };
-  }
-
-  @Override
-  protected PhraseQuery newPhraseQuery() {
-    return new PhraseQuery() {
-
-      @Override
-      public void add(Term term, int position) {
-        super.add(term, position);
-        addField(this, term.field());
-      }
-    };
+  private SuperQuery newSuperQuery(Query query) {
+    return new SuperQuery(wrapFilter(query), _scoreType, _defaultPrimeDocTerm);
   }
 
-  @Override
-  protected Query newPrefixQuery(Term prefix) {
-    String field = prefix.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support prefix queries.");
+  private Query wrapFilter(Query query) {
+    if (_queryFilter == null) {
+      return query;
     }
-    return addField(super.newPrefixQuery(prefix), field);
+    return new FilteredQuery(query, _queryFilter);
   }
 
-  @Override
-  protected Query newRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    Query q = _blurAnalyzer.getNewRangeQuery(field, part1, part2, startInclusive, endInclusive);
-    if (q != null) {
-      return addField(q, field);
+  private boolean isSameGroupName(BooleanQuery booleanQuery) {
+    String groupName = findFirstGroupName(booleanQuery);
+    if (groupName == null) {
+      return false;
     }
-    return addField(super.newRangeQuery(field, part1, part2, startInclusive, endInclusive),
field);
+    return isSameGroupName(booleanQuery, groupName);
   }
 
-  @Override
-  protected Query newTermQuery(Term term) {
-    String field = term.field();
-    Query q = _blurAnalyzer.getNewRangeQuery(field, term.text(), term.text(), true, true);
-    if (q != null) {
-      return addField(q, field);
+  private boolean isSameGroupName(Query query, String groupName) {
+    if (query instanceof BooleanQuery) {
+      BooleanQuery booleanQuery = (BooleanQuery) query;
+      for (BooleanClause clause : booleanQuery.clauses()) {
+        if (!isSameGroupName(clause.getQuery(), groupName)) {
+          return false;
+        }
+      }
+      return true;
+    } else {
+      String fieldName = _fieldNames.get(query);
+      String currentGroupName = getGroupName(fieldName);
+      if (groupName.equals(currentGroupName)) {
+        return true;
+      }
+      return false;
     }
-    return addField(super.newTermQuery(term), field);
   }
 
-  @Override
-  protected Query newWildcardQuery(Term t) {
-    if (SUPER.equals(t.field()) && "*".equals(t.text())) {
-      return new MatchAllDocsQuery();
+  private String getGroupName(String fieldName) {
+    if (fieldName == null) {
+      return null;
     }
-    String field = t.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type
-          + "] which does not support wildcard queries.");
+    int index = fieldName.indexOf(SEP);
+    if (index < 0) {
+      return null;
     }
-    return addField(super.newWildcardQuery(t), t.field());
+    return fieldName.substring(0, index);
   }
 
-  private SuperQuery newSuperQuery(Query query) {
-    return new SuperQuery(wrapFilter(query), _scoreType, _defaultPrimeDocTerm);
-  }
-
-  private Query wrapFilter(Query query) {
-    if (_queryFilter == null) {
-      return query;
+  private String findFirstGroupName(Query query) {
+    if (query instanceof BooleanQuery) {
+      BooleanQuery booleanQuery = (BooleanQuery) query;
+      for (BooleanClause clause : booleanQuery.clauses()) {
+        return findFirstGroupName(clause.getQuery());
+      }
+      return null;
+    } else if (query instanceof SuperQuery) {
+      SuperQuery sq = (SuperQuery) query;
+      return findFirstGroupName(sq.getQuery());
+    } else {
+      String fieldName = _fieldNames.get(query);
+      return getGroupName(fieldName);
     }
-    return new FilteredQuery(query, _queryFilter);
   }
 
-  // private boolean isSameGroupName(BooleanQuery booleanQuery) {
-  // String groupName = findFirstGroupName(booleanQuery);
-  // if (groupName == null) {
-  // return false;
-  // }
-  // return isSameGroupName(booleanQuery, groupName);
-  // }
-  //
-  // private boolean isSameGroupName(Query query, String groupName) {
-  // if (query instanceof BooleanQuery) {
-  // BooleanQuery booleanQuery = (BooleanQuery) query;
-  // for (BooleanClause clause : booleanQuery.clauses()) {
-  // if (!isSameGroupName(clause.getQuery(), groupName)) {
-  // return false;
-  // }
-  // }
-  // return true;
-  // } else {
-  // String fieldName = fieldNames.get(query);
-  // String currentGroupName = getGroupName(fieldName);
-  // if (groupName.equals(currentGroupName)) {
-  // return true;
-  // }
-  // return false;
-  // }
-  // }
-  //
-  // private String getGroupName(String fieldName) {
-  // if (fieldName == null) {
-  // return null;
-  // }
-  // int index = fieldName.indexOf(SEP);
-  // if (index < 0) {
-  // return null;
-  // }
-  // return fieldName.substring(0, index);
-  // }
-  //
-  // private String findFirstGroupName(Query query) {
-  // if (query instanceof BooleanQuery) {
-  // BooleanQuery booleanQuery = (BooleanQuery) query;
-  // for (BooleanClause clause : booleanQuery.clauses()) {
-  // return findFirstGroupName(clause.getQuery());
-  // }
-  // return null;
-  // } else {
-  // String fieldName = fieldNames.get(query);
-  // return getGroupName(fieldName);
-  // }
-  // }
-
   private Query reprocess(Query query) {
     if (query == null || !isSuperSearch()) {
       return wrapFilter(query);
@@ -332,26 +245,11 @@ public class SuperParser extends QueryParser {
         bc.setQuery(newSuperQuery(q));
       }
       return booleanQuery;
-
-      // if (isSameGroupName(booleanQuery)) {
-      // return newSuperQuery(query);
-      // } else {
-      // List<BooleanClause> clauses = booleanQuery.clauses();
-      // for (BooleanClause clause : clauses) {
-      // clause.setQuery(reprocess(clause.getQuery()));
-      // }
-      // return booleanQuery;
-      // }
     } else {
       return newSuperQuery(query);
     }
   }
 
-  private Query addField(Query q, String field) {
-    _fieldNames.put(q, field);
-    return q;
-  }
-
   public boolean isSuperSearch() {
     return _superSearch;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fd208bad/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 497b11a..93a52bb 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
@@ -46,13 +46,13 @@ public class SuperParserTest {
   }
 
   @Test
-  public void testParser1() throws ParseException {
-    Query query = parser.parse(" +super:<a:a d:e b:b> ");
+  public void test1() throws ParseException {
+    Query query = parser.parse(" +super:<a.a:a a.d:e a.b:b> ");
 
     BooleanQuery booleanQuery = new BooleanQuery();
-    booleanQuery.add(new TermQuery(new Term("a", "a")), Occur.SHOULD);
-    booleanQuery.add(new TermQuery(new Term("d", "e")), Occur.SHOULD);
-    booleanQuery.add(new TermQuery(new Term("b", "b")), Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term("a.a", "a")), Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term("a.d", "e")), Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term("a.b", "b")), Occur.SHOULD);
     SuperQuery superQuery = new SuperQuery(booleanQuery, ScoreType.SUPER, new Term("_primedoc_"));
 
     BooleanQuery bq = new BooleanQuery();
@@ -63,12 +63,12 @@ public class SuperParserTest {
   }
 
   @Test
-  public void testParser2() throws ParseException {
-    Query query = parser.parse("super:<c:c d:d>");
+  public void test2() throws ParseException {
+    Query query = parser.parse("super:<a.c:c a.d:d>");
 
     BooleanQuery booleanQuery = new BooleanQuery();
-    booleanQuery.add(new TermQuery(new Term("c", "c")), Occur.SHOULD);
-    booleanQuery.add(new TermQuery(new Term("d", "d")), Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term("a.c", "c")), Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term("a.d", "d")), Occur.SHOULD);
     SuperQuery superQuery = new SuperQuery(booleanQuery, ScoreType.SUPER, new Term("_primedoc_"));
 
     BooleanQuery bq = new BooleanQuery();
@@ -78,23 +78,23 @@ public class SuperParserTest {
   }
 
   @Test
-  public void testParser3() throws ParseException {
+  public void test3() throws ParseException {
     Query query = parser.parse("a:a d:e b:b");
     assertQuery(bq(bc(sq(tq("a", "a"))), bc(sq(tq("d", "e"))), bc(sq(tq("b", "b")))), query);
   }
 
   @Test
-  public void testParser4() throws ParseException {
-    Query query = parser.parse("super:<a:a d:e b:b>  - super:<c:c d:d>");
+  public void test4() throws ParseException {
+    Query query = parser.parse("super:<a.a:a a.d:e a.b:b>  - super:<b.c:c b.d:d>");
 
     BooleanQuery booleanQuery1 = new BooleanQuery();
-    booleanQuery1.add(new TermQuery(new Term("a", "a")), Occur.SHOULD);
-    booleanQuery1.add(new TermQuery(new Term("d", "e")), Occur.SHOULD);
-    booleanQuery1.add(new TermQuery(new Term("b", "b")), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.a", "a")), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.d", "e")), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.b", "b")), Occur.SHOULD);
 
     BooleanQuery booleanQuery2 = new BooleanQuery();
-    booleanQuery2.add(new TermQuery(new Term("c", "c")), Occur.SHOULD);
-    booleanQuery2.add(new TermQuery(new Term("d", "d")), Occur.SHOULD);
+    booleanQuery2.add(new TermQuery(new Term("b.c", "c")), Occur.SHOULD);
+    booleanQuery2.add(new TermQuery(new Term("b.d", "d")), Occur.SHOULD);
 
     SuperQuery superQuery1 = new SuperQuery(booleanQuery1, ScoreType.SUPER, new Term("_primedoc_"));
     SuperQuery superQuery2 = new SuperQuery(booleanQuery2, ScoreType.SUPER, new Term("_primedoc_"));
@@ -107,21 +107,21 @@ public class SuperParserTest {
   }
 
   @Test
-  public void testParser5() throws ParseException {
+  public void test5() throws ParseException {
     parser = new SuperParser(LUCENE_VERSION, new BlurAnalyzer(new WhitespaceAnalyzer(LUCENE_VERSION)),
true, null,
         ScoreType.SUPER, new Term("_primedoc_"));
-    Query query = parser.parse("super:<a:a d:{e TO f} b:b test:hello\\<> - super:<c:c
d:d>");
+    Query query = parser.parse("super:<a.a:a a.d:{e TO f} a.b:b a.test:hello\\<>
- super:<g.c:c g.d:d>");
 
     BooleanQuery booleanQuery1 = new BooleanQuery();
-    booleanQuery1.add(new TermQuery(new Term("a", "a")), Occur.SHOULD);
-    booleanQuery1.add(new TermRangeQuery("d", new BytesRef("e"), new BytesRef("f"), false,
false), Occur.SHOULD);
-    booleanQuery1.add(new TermQuery(new Term("b", "b")), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.a", "a")), Occur.SHOULD);
+    booleanQuery1.add(new TermRangeQuery("a.d", new BytesRef("e"), new BytesRef("f"), false,
false), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.b", "b")), Occur.SHOULD);
     // std analyzer took the "<" out
-    booleanQuery1.add(new TermQuery(new Term("test", "hello<")), Occur.SHOULD);
+    booleanQuery1.add(new TermQuery(new Term("a.test", "hello<")), Occur.SHOULD);
 
     BooleanQuery booleanQuery2 = new BooleanQuery();
-    booleanQuery2.add(new TermQuery(new Term("c", "c")), Occur.SHOULD);
-    booleanQuery2.add(new TermQuery(new Term("d", "d")), Occur.SHOULD);
+    booleanQuery2.add(new TermQuery(new Term("g.c", "c")), Occur.SHOULD);
+    booleanQuery2.add(new TermQuery(new Term("g.d", "d")), Occur.SHOULD);
 
     SuperQuery superQuery1 = new SuperQuery(booleanQuery1, ScoreType.SUPER, new Term("_primedoc_"));
     SuperQuery superQuery2 = new SuperQuery(booleanQuery2, ScoreType.SUPER, new Term("_primedoc_"));
@@ -134,7 +134,7 @@ public class SuperParserTest {
   }
 
   @Test
-  public void testParser6() throws ParseException {
+  public void test6() throws ParseException {
     SuperParser parser = new SuperParser(LUCENE_VERSION, analyzer, true, null, ScoreType.SUPER,
new Term("_primedoc_"));
     try {
       parser.parse("super : <a:a d:{e TO d} b:b super:<test:hello\\<>> super:<c:c
d:d>");
@@ -384,12 +384,8 @@ public class SuperParserTest {
   }
 
   private Query parseSq(String qstr) throws ParseException {
-    return parseSq(qstr, false);
-  }
-
-  private Query parseSq(String qstr, boolean autoGrouping) throws ParseException {
     SuperParser superParser = new SuperParser(LUCENE_VERSION, analyzer, true, null, ScoreType.SUPER,
new Term(
-        "_primedoc_"), autoGrouping);
+        "_primedoc_"));
     return superParser.parse(qstr);
   }
 


Mime
View raw message