Package org.apache.lucene.search

Examples of org.apache.lucene.search.TermRangeQuery


    assertTrue(reader.getRefCount() > 0);
    IndexReader wrappedReader = SlowCompositeReaderWrapper.wrap(reader);
    wrappedReader = new ParallelAtomicReader((AtomicReader) wrappedReader);

    IndexSearcher searcher = newSearcher(wrappedReader);
    TermRangeQuery query = TermRangeQuery.newStringRange("field", "a", "z", true, true);
    searcher.search(query, 5);
    reader.close(); // close original child reader
    try {
      searcher.search(query, 5);
    } catch (AlreadyClosedException ace) {
View Full Code Here


    defgMultiTermQueryTest(new RegexpQuery (term));
  }

  public void testRangeQuery() throws Exception {
    makeIndexStrMV();
    defgMultiTermQueryTest(new TermRangeQuery (F, new BytesRef("d"), new BytesRef("e"), true, true));
  }
View Full Code Here

  protected Query newRangeQuery(String field, String part1, String part2,
      boolean startInclusive, boolean endInclusive) {
    if (isPass2ResolvingPhrases) {
      // Must use old-style RangeQuery in order to produce a BooleanQuery
      // that can be turned into SpanOr clause
      TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, part1, part2, startInclusive, endInclusive);
      rangeQuery.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
      return rangeQuery;
    }
    return super.newRangeQuery(field, part1, part2, startInclusive, endInclusive);
  }
View Full Code Here

  protected Query newRangeQuery(String field, String part1, String part2,
      boolean inclusive) {
    if (isPass2ResolvingPhrases) {
      // Must use old-style RangeQuery in order to produce a BooleanQuery
      // that can be turned into SpanOr clause
      TermRangeQuery rangeQuery = new TermRangeQuery(field, part1, part2, inclusive, inclusive,
          getRangeCollator());
      rangeQuery.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
      return rangeQuery;
    }
    return super.newRangeQuery(field, part1, part2, inclusive);
  }
View Full Code Here

        } else if (!(isLongField && isNumeric)){
         
          BytesRef minValBytes = new BytesRef(minValue);
          BytesRef maxValBytes = new BytesRef(maxValue);
         
          query = new TermRangeQuery(fieldName, minValBytes, maxValBytes, isIncludeMin, isIncludeMax);
         
        } else {
          logger.error("범위검색은 필드의 타입과 쿼리의 타입이 맞아야 합니다. {} " , userRequestQuery);
          throw new CrescentInvalidRequestException("범위검색은 필드의 타입과 쿼리의 타입이 맞아야 합니다. [" + userRequestQuery + "]");
        }
View Full Code Here

   * @param part2 max
   * @param inclusive true if range is inclusive
   * @return new TermRangeQuery instance
   */
  protected Query newRangeQuery(String field, String part1, String part2, boolean inclusive) {
    final TermRangeQuery query = new TermRangeQuery(field, part1, part2, inclusive, inclusive, rangeCollator);
    query.setRewriteMethod(multiTermRewriteMethod);
    return query;
  }
View Full Code Here

      lowerInclusive = true;
    }

    String field = rangeNode.getField().toString();

    TermRangeQuery rangeQuery = new TermRangeQuery(field, lower
        .getTextAsString(), upper.getTextAsString(), lowerInclusive,
        upperInclusive, rangeNode.getCollator());
   
    MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID);
    if (method != null) {
      rangeQuery.setRewriteMethod(method);
    }

    return rangeQuery;

  }
View Full Code Here

  protected Query newRangeQuery(String field, String part1, String part2,
      boolean inclusive) {
    if (isPass2ResolvingPhrases) {
      // Must use old-style RangeQuery in order to produce a BooleanQuery
      // that can be turned into SpanOr clause
      TermRangeQuery rangeQuery = new TermRangeQuery(field, part1, part2, inclusive, inclusive,
          getRangeCollator());
      rangeQuery.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
      return rangeQuery;
    }
    return super.newRangeQuery(field, part1, part2, inclusive);
  }
View Full Code Here

                      Field.Store.YES, Field.Index.ANALYZED));
    writer.addDocument(doc);
    writer.close();
    IndexSearcher searcher = new IndexSearcher(ramDir);

    Query query = new TermRangeQuery("content", firstBeg, firstEnd, true, true);
    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
    assertEquals("The index Term should not be included.", 0, hits.length);

    query = new TermRangeQuery("content", secondBeg, secondEnd, true, true);
    hits = searcher.search(query, null, 1000).scoreDocs;
    assertEquals("The index Term should be included.", 1, hits.length);
    searcher.close();
  }
View Full Code Here

   
  }
 
  private MultiTermQuery copyMultiTermQuery(MultiTermQuery query) {
    if(query instanceof TermRangeQuery) {
      TermRangeQuery q = (TermRangeQuery)query;
      q.setBoost(query.getBoost());
      return new TermRangeQuery(q.getField(), q.getLowerTerm(), q.getUpperTerm(), q.includesLower(), q.includesUpper());
    } else if(query instanceof WildcardQuery) {
      MultiTermQuery q = new WildcardQuery(query.getTerm());
      q.setBoost(query.getBoost());
      return q;
    } else if(query instanceof PrefixQuery) {
      MultiTermQuery q = new PrefixQuery(query.getTerm());
      q.setBoost(q.getBoost());
      return q;
    } else if(query instanceof FuzzyQuery) {
      FuzzyQuery q = (FuzzyQuery)query;
      q.setBoost(q.getBoost());
      return new FuzzyQuery(q.getTerm(), q.getMinSimilarity(), q.getPrefixLength());
    }
   
    return query;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.TermRangeQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.