Package org.apache.lucene.search

Examples of org.apache.lucene.search.ConstantScoreRangeQuery


        f.add("dynamicBase", schema.getDynamicPattern(sfield.getName()));
      }

      // If numTerms==0, the call is just asking for a quick field list
      if( ttinfo != null && sfield != null && sfield.indexed() ) {
        Query q = new ConstantScoreRangeQuery(fieldName,null,null,false,false);
        TopDocs top = searcher.search( q, 1 );
        if( top.totalHits > 0 ) {
          // Find a document with this field
          try {
            Document doc = searcher.doc( top.scoreDocs[0].doc );
View Full Code Here


                            new Term(field, part2),
                            inclusive, rangeCollator);
    }
    else
    {
      return new ConstantScoreRangeQuery
        (field, part1, part2, inclusive, inclusive, rangeCollator);
    }
  }
View Full Code Here

     * @return the rewritten query or this query if rewriting is not possible.
     * @throws IOException if an error occurs.
     */
    public Query rewrite(IndexReader reader) throws IOException {
        if (transform == TRANSFORM_NONE) {
            return new ConstantScoreRangeQuery(lowerTerm.field(),
                    lowerTerm.text(), upperTerm.text(), inclusive,
                    inclusive).rewrite(reader);
        } else {
            // always use our implementation when we need to transform the
            // term enum
View Full Code Here

        SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps, inorder);
        sp.setBoost(query.getBoost());
        extractWeightedSpanTerms(terms, sp);
      }
    } else if (highlightCnstScrRngQuery && query instanceof ConstantScoreRangeQuery) {
      ConstantScoreRangeQuery q = (ConstantScoreRangeQuery) query;
      Term lower = new Term(fieldName, q.getLowerVal());
      Term upper = new Term(fieldName, q.getUpperVal());
      FilterIndexReader fir = new FilterIndexReader(getReaderForField(fieldName));
      try {
        TermEnum te = fir.terms(lower);
        BooleanQuery bq = new BooleanQuery();
        do {
View Full Code Here

                            new Term(field, part2),
                            inclusive, rangeCollator);
    }
    else
    {
      return new ConstantScoreRangeQuery
        (field, part1, part2, inclusive, inclusive, rangeCollator);
    }
  }
View Full Code Here

  public void testGetConstantScoreRangeFragments() throws Exception {

    numHighlights = 0;

    query = new ConstantScoreRangeQuery(FIELD_NAME, "kannedy", "kznnedy", true, true);

    searcher = new IndexSearcher(ramDir);
    // can't rewrite ConstantScoreRangeQuery if you want to highlight it -
    // it rewrites to ConstantScoreQuery which cannot be highlighted
    // query = unReWrittenQuery.rewrite(reader);
View Full Code Here

    // orders the U+0698 character before the U+0633 character, so the single
    // index Term below should NOT be returned by a ConstantScoreRangeQuery
    // with a Farsi Collator (or an Arabic one for the case when Farsi is
    // not supported).
    Query csrq
      = new ConstantScoreRangeQuery("content", firstBeg, firstEnd, true, true);
    ScoreDoc[] result = search.search(csrq, null, 1000).scoreDocs;
    assertEquals("The index Term should not be included.", 0, result.length);

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

     * @return the rewritten query or this query if rewriting is not possible.
     * @throws IOException if an error occurs.
     */
    public Query rewrite(IndexReader reader) throws IOException {
        if (transform == TRANSFORM_NONE) {
            return new ConstantScoreRangeQuery(lowerTerm.field(),
                    lowerTerm.text(), upperTerm.text(), inclusive,
                    inclusive).rewrite(reader);
        } else {
            // always use our implementation when we need to transform the
            // term enum
View Full Code Here

     * @throws IOException if an error occurs.
     */
    @Override
   public Query rewrite(IndexReader reader) throws IOException {
        if (transform == TRANSFORM_NONE) {
            return new ConstantScoreRangeQuery(lowerTerm.field(),
                    lowerTerm.text(), upperTerm.text(), inclusive,
                    inclusive).rewrite(reader);
        } else {
            // always use our implementation when we need to transform the
            // term enum
View Full Code Here

      case IS_GREATER_THAN: {
        Term lowerBound = new Term(fieldname, MIN_DATE);
        Term upperBound = new Term(fieldname, value);

        return new ConstantScoreRangeQuery(fieldname, lowerBound.text(), upperBound.text(), false, false);
      }

      case IS_LESS_THAN: {
        Term lowerBound = new Term(fieldname, value);
        Term upperBound = new Term(fieldname, MAX_DATE);

        return new ConstantScoreRangeQuery(fieldname, lowerBound.text(), upperBound.text(), false, false);
      }
    }

    throw new UnsupportedOperationException("Unsupported Specifier for Age Query"); //$NON-NLS-1$
  }
View Full Code Here

TOP

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

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.