@Test public void test5() throws ParseException, IOException { parser = new SuperParser(LUCENE_VERSION, getFieldManager(new WhitespaceAnalyzer(LUCENE_VERSION)), true, null, ScoreType.SUPER, new Term("_primedoc_")); Query query = parser.parse("<a.a:a a.d:{e TO f} a.b:b a.test:hello\\<> -<g.c:c g.d:d>"); BooleanQuery booleanQuery1 = new BooleanQuery(); 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); booleanQuery1.add(new TermQuery(new Term("a.test", "hello<")), Occur.SHOULD); BooleanQuery booleanQuery2 = new BooleanQuery(); 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_")); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add(superQuery1, Occur.SHOULD); booleanQuery.add(superQuery2, Occur.MUST_NOT); assertQuery(booleanQuery, query); }
public Query parse(final String queryStr) throws ParseException { final Map<String, Query> subQueries = new HashMap<String, Query>(); final StringBuilder builder = new StringBuilder(); match(queryStr, new Group() { int _subQueryIndex = 0; @Override public void match(int start, int end) throws ParseException { if (_lastStart != start) { builder.append(queryStr.substring(_lastEnd, start)); } String realQuery = queryStr.substring(start, end); LOG.debug("Realquery [{0}]", realQuery); String superQueryStr = getMatchText(realQuery); LOG.debug("Parseable sub query [{0}]", superQueryStr); String key = _prefixToSub + _subQueryIndex; QueryParser newParser = getNewParser(); Query query = newParser.parse(superQueryStr); if (!isSameGroupName(query)) { throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family."); } if (_superSearch) { query = newSuperQuery(query); } else { query = wrapFilter(query); } subQueries.put(key, query); builder.append(_prefixToSub).append(':').append(_subQueryIndex); _subQueryIndex++; _lastStart = start; _lastEnd = end; } private String getMatchText(String match) { return match.substring(1, match.length() - 1); } }); if (_lastEnd < queryStr.length()) { builder.append(queryStr.substring(_lastEnd)); } Query query = super.parse(builder.toString()); return fixNegatives(reprocess(replaceRealQueries(query, subQueries))); }
SuperParser extends BlurQueryParser { public Query parse(final String queryStr) throws ParseException { final Map<String, Query> subQueries = new HashMap<String, Query>(); final StringBuilder builder = new StringBuilder(); match(queryStr, new Group() { int _subQueryIndex = 0; @Override public void match(int start, int end) throws ParseException { if (_lastStart != start) { builder.append(queryStr.substring(_lastEnd, start)); } String realQuery = queryStr.substring(start, end); LOG.debug("Realquery [{0}]", realQuery); String superQueryStr = getMatchText(realQuery); LOG.debug("Parseable sub query [{0}]", superQueryStr); String key = _prefixToSub + _subQueryIndex; QueryParser newParser = getNewParser(); Query query = newParser.parse(superQueryStr); if (!isSameGroupName(query)) { throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family."); } if (_superSearch) { query = newSuperQuery(query); } else { query = wrapFilter(query); } subQueries.put(key, query); builder.append(_prefixToSub).append(':').append(_subQueryIndex); _subQueryIndex++; _lastStart = start; _lastEnd = end; } private String getMatchText(String match) { return match.substring(1, match.length() - 1); } }); if (_lastEnd < queryStr.length()) { builder.append(queryStr.substring(_lastEnd)); } Query query = super.parse(builder.toString()); return fixNegatives(reprocess(replaceRealQueries(query, subQueries))); } }
SuperParser extends BlurQueryParser { public Query parse(final String queryStr) throws ParseException { final Map<String, Query> subQueries = new HashMap<String, Query>(); final StringBuilder builder = new StringBuilder(); match(queryStr, new Group() { int _subQueryIndex = 0; @Override public void match(int start, int end) throws ParseException { if (_lastStart != start) { builder.append(queryStr.substring(_lastEnd, start)); } String realQuery = queryStr.substring(start, end); LOG.debug("Realquery [{0}]", realQuery); String superQueryStr = getMatchText(realQuery); LOG.debug("Parseable sub query [{0}]", superQueryStr); String key = _prefixToSub + _subQueryIndex; QueryParser newParser = getNewParser(); Query query = newParser.parse(superQueryStr); if (!isSameGroupName(query)) { throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family."); } if (_superSearch) { query = newSuperQuery(query); } else { query = wrapFilter(query); } subQueries.put(key, query); builder.append(_prefixToSub).append(':').append(_subQueryIndex); _subQueryIndex++; _lastStart = start; _lastEnd = end; } private String getMatchText(String match) { return match.substring(1, match.length() - 1); } }); if (_lastEnd < queryStr.length()) { builder.append(queryStr.substring(_lastEnd)); } Query query = super.parse(builder.toString()); return fixNegatives(reprocess(replaceRealQueries(query, subQueries))); } SuperParser(Version matchVersion, FieldManager fieldManager, boolean superSearch, Filter queryFilter,
      ScoreType scoreType, Term defaultPrimeDocTerm); }
SuperParser extends BlurQueryParser { public Query parse(final String queryStr) throws ParseException { final Map<String, Query> subQueries = new HashMap<String, Query>(); final StringBuilder builder = new StringBuilder(); match(queryStr, new Group() { int _subQueryIndex = 0; @Override public void match(int start, int end) throws ParseException { if (_lastStart != start) { builder.append(queryStr.substring(_lastEnd, start)); } String realQuery = queryStr.substring(start, end); LOG.debug("Realquery [{0}]", realQuery); String superQueryStr = getMatchText(realQuery); LOG.debug("Parseable sub query [{0}]", superQueryStr); String key = _prefixToSub + _subQueryIndex; QueryParser newParser = getNewParser(); Query query = newParser.parse(superQueryStr); if (!isSameGroupName(query)) { throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family."); } if (_superSearch) { query = newSuperQuery(query); } else { query = wrapFilter(query); } subQueries.put(key, query); builder.append(_prefixToSub).append(':').append(_subQueryIndex); _subQueryIndex++; _lastStart = start; _lastEnd = end; } private String getMatchText(String match) { return match.substring(1, match.length() - 1); } }); if (_lastEnd < queryStr.length()) { builder.append(queryStr.substring(_lastEnd)); } Query query = super.parse(builder.toString()); return fixNegatives(reprocess(replaceRealQueries(query, subQueries))); } SuperParser(Version matchVersion, FieldManager fieldManager, boolean superSearch, Filter queryFilter,
      ScoreType scoreType, Term defaultPrimeDocTerm); Query parse(final String queryStr); }
SuperParser extends BlurQueryParser { public Query parse(final String queryStr) throws ParseException { final Map<String, Query> subQueries = new HashMap<String, Query>(); final StringBuilder builder = new StringBuilder(); match(queryStr, new Group() { int _subQueryIndex = 0; @Override public void match(int start, int end) throws ParseException { if (_lastStart != start) { builder.append(queryStr.substring(_lastEnd, start)); } String realQuery = queryStr.substring(start, end); LOG.debug("Realquery [{0}]", realQuery); String superQueryStr = getMatchText(realQuery); LOG.debug("Parseable sub query [{0}]", superQueryStr); String key = _prefixToSub + _subQueryIndex; QueryParser newParser = getNewParser(); Query query = newParser.parse(superQueryStr); if (!isSameGroupName(query)) { throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family."); } if (_superSearch) { query = newSuperQuery(query); } else { query = wrapFilter(query); } subQueries.put(key, query); builder.append(_prefixToSub).append(':').append(_subQueryIndex); _subQueryIndex++; _lastStart = start; _lastEnd = end; } private String getMatchText(String match) { return match.substring(1, match.length() - 1); } }); if (_lastEnd < queryStr.length()) { builder.append(queryStr.substring(_lastEnd)); } Query query = super.parse(builder.toString()); return fixNegatives(reprocess(replaceRealQueries(query, subQueries))); } SuperParser(Version matchVersion, FieldManager fieldManager, boolean superSearch, Filter queryFilter,
      ScoreType scoreType, Term defaultPrimeDocTerm); Query parse(final String queryStr);  }