Package org.apache.lucene.search

Examples of org.apache.lucene.search.RangeQuery


      part1 = DateTools.dateToString(d1, DateTools.Resolution.DAY);
      part2 = DateTools.dateToString(d2, DateTools.Resolution.DAY);
    }
    catch (Exception e) { }

    return new RangeQuery(new Term(field, part1),
                          new Term(field, part2),
                          inclusive);
  }
View Full Code Here


   * @return new RangeQuery instance
   */
  protected Query newRangeQuery(String field, String part1, String part2, boolean inclusive) {
    if(useOldRangeQuery)
    {
      return new RangeQuery(new Term(field, part1),
                            new Term(field, part2),
                            inclusive, rangeCollator);
    }
    else
    {
View Full Code Here

      part1 = DateTools.dateToString(d1, DateTools.Resolution.DAY);
      part2 = DateTools.dateToString(d2, DateTools.Resolution.DAY);
    }
    catch (Exception e) { }

    return new RangeQuery(new Term(field, part1),
                          new Term(field, part2),
                          inclusive);
  }
View Full Code Here

 
  public void testRangeQuery() throws Exception {

    numHighlights = 0;

    query = new RangeQuery(new Term(FIELD_NAME, "kannedy"), new Term(FIELD_NAME, "kznnedy"), 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

        Term searchTerm = new Term(searchField, searchDate);

        switch (relation) {
        case GeoProfile.LESS_THAN:
        case GeoProfile.BEFORE:
            returnQuery = new RangeQuery(null, lowTerm, false);

            break;

        case GeoProfile.BEFORE_OR_DURING:
        case GeoProfile.LESS_THAN_EQUAL:
            returnQuery = new RangeQuery(null, highTerm, true);

            break;

        case GeoProfile.DURING:
        case GeoProfile.EQUALS:default:

            if (twoDates) {
                returnQuery = new RangeQuery(lowTerm, highTerm, true);

                //must be between low and high, inclusive.
            } else {
                returnQuery = new PrefixQuery(lowTerm);

                //even if a full ccyymmdd date term prefix query doesn't hurt.
            }

            break;

        case GeoProfile.DURING_OR_AFTER:
        case GeoProfile.GREATER_THAN_EQUAL:
            returnQuery = new RangeQuery(lowTerm, null, true);

            break;

        case GeoProfile.AFTER:
        case GeoProfile.GREATER_THAN:
            returnQuery = new RangeQuery(highTerm, null, false);

            break;

        case GeoProfile.NOT_EQUAL:
            returnQuery = notEqualQuery(new PrefixQuery(lowTerm));
View Full Code Here

            Term numTerm = new Term(searchField, searchNumber);

            switch (relation) {
            case GeoProfile.LESS_THAN:
                returnQuery = new RangeQuery(null, numTerm, false);

                break;

            case GeoProfile.LESS_THAN_EQUAL:
                returnQuery = new RangeQuery(null, numTerm, true);

                break;

            case GeoProfile.EQUALS:
                returnQuery = new TermQuery(numTerm);

                break;

            case GeoProfile.GREATER_THAN_EQUAL:
                returnQuery = new RangeQuery(numTerm, null, true);

                break;

            case GeoProfile.GREATER_THAN:
                returnQuery = new RangeQuery(numTerm, null, false);

                break;

            case GeoProfile.NOT_EQUAL:
                returnQuery = notEqualQuery(new TermQuery(numTerm));
View Full Code Here

        if (north != null) {
            Term southTerm = new Term(attrMap.getProperty(
                        GeoProfile.Attribute.SOUTHBC), north);

            //the southbc field must be less than the north passed in.
            retQuery.add(new RangeQuery(null, southTerm, true), true, false);
        }

        if (south != null) {
            Term northTerm = new Term(attrMap.getProperty(
                        GeoProfile.Attribute.NORTHBC), south);

            //the northbc field must be greater than the southbc passed in.
            retQuery.add(new RangeQuery(northTerm, null, true), true, false);
        }

        if (east != null) {
            Term westTerm = new Term(attrMap.getProperty(
                        GeoProfile.Attribute.WESTBC), east);

            //the westbc field must be less than the east passed in.
            retQuery.add(new RangeQuery(null, westTerm, true), true, false);
        }

        if (west != null) {
            Term eastTerm = new Term(attrMap.getProperty(
                        GeoProfile.Attribute.EASTBC), west);

            //the eastbc field must be greater than the westbc passed in.
            retQuery.add(new RangeQuery(eastTerm, null, true), true, false);
        }

        return retQuery;
    }
View Full Code Here

 
  public void testRangeQuery() throws Exception {

    numHighlights = 0;

    query = new RangeQuery(new Term(FIELD_NAME, "kannedy"), new Term(FIELD_NAME, "kznnedy"), 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

TOP

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

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.