Package org.apache.lucene.search

Examples of org.apache.lucene.search.RangeQuery


        cal.set(Calendar.HOUR, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        Term end = new Term("moment", DateField.dateToString(cal.getTime()));

        query.add(new RangeQuery(begin, end, true), true, false);
      }
      catch (Exception e)
      {
        bean.addValidationError(new ValidationError.WRONGFORMAT("date"));
      }
    }

    boolean beginDatePresent = (bean.getBeginDate() != null && !bean.getBeginDate().equals(""));
    boolean endDatePresent = (bean.getEndDate() != null && !bean.getEndDate().equals(""));

    if (beginDatePresent && endDatePresent)
    {
      String beginDateFormatted = null;
      String endDateFormatted = null;
      try
      {
        Date beginDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getBeginDate());
        Date endDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getEndDate());

        Calendar cal = Calendar.getInstance();
        cal.setTime(endDateParsed);

        cal.set(Calendar.HOUR, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);

        beginDateFormatted = DateField.dateToString(beginDateParsed);
        endDateFormatted = DateField.dateToString(cal.getTime());
      }
      catch (ParseException e)
      {
        bean.addValidationError(new ValidationError.WRONGFORMAT("beginDate"));
        bean.addValidationError(new ValidationError.WRONGFORMAT("endDate"));
      }

      if (bean.getValidationErrors().size() == 0)
      {
        Term begin = new Term("moment", beginDateFormatted);
        Term end = new Term("moment", endDateFormatted);

        query.add(new RangeQuery(begin, end, true), true, false);
      }
    }
    else if (!beginDatePresent && !endDatePresent)
    {
      // noop; means they didn't try a date range
View Full Code Here


    if (null!=sSeverity)
      if (sSeverity.length()>0)
      oQry.add(new TermQuery(new Term("severity",sSeverity)),BooleanClause.Occur.MUST);

    if (dtFromDate!=null && dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtFromDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(new Date(299,11,31), DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(new Date(79,11,31), DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);
    if (null!=sText)
      if (sText.length()>0)
      oQry.add(new TermQuery(new Term("text",sText)),BooleanClause.Occur.SHOULD);
View Full Code Here

    if (null!=sNewsGroupCategoryName)
    oQrx.add(new TermQuery(new Term("container",sNewsGroupCategoryName)),BooleanClause.Occur.MUST);   

    if (dtFromDate!=null && dtToDate!=null)
    oQrx.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtFromDate!=null)
    oQrx.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(new Date(299,11,31), DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtToDate!=null)
    oQrx.add(new RangeQuery(new Term("created",DateTools.dateToString(new Date(79,11,31), DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   

  BooleanQuery oQry = new BooleanQuery();

  if (null!=sAuthor)
View Full Code Here

     
    if (null!=sSubject)
      oQry.add(new TermQuery(new Term("title",Gadgets.ASCIIEncode(sSubject))),BooleanClause.Occur.MUST);
  
    if (dtFromDate!=null && dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtFromDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(new Date(299,11,31), DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(new Date(79,11,31), DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);

    if (null!=sText)
      oQry.add(new TermQuery(new Term("text",sText)),BooleanClause.Occur.SHOULD);
View Full Code Here

      LOGGER.error(message);
      throw new QueryException(message);
    }
   
    // Inclusive of upper term.
    RangeQuery rangeQuery = new RangeQuery(getTerm(iLower),
      getTerm(iUpper), true);
    // 0.0f triggers filterization.  We want this.
    rangeQuery.setBoost(0.0f);
    output.add(rangeQuery,
      (c.isRequired() == true && c.isProhibited() == false)?
      BooleanClause.Occur.MUST:
      (c.isRequired() == false && c.isProhibited() == false)?
      BooleanClause.Occur.SHOULD:
View Full Code Here

            if (this.startFieldEndValue != null) {
                startFieldEndTerm = new Term(this.startFieldName,
                        this.startFieldEndValue);
            }

            RangeQuery query1 = new RangeQuery(startFieldStartTerm,
                    startFieldEndTerm, true);
            booleanQuery.add(query1, BooleanClause.Occur.MUST);

            if (this.endFieldName != null
                    && (this.endFieldStartValue != null || this.endFieldEndValue != null)) {
                Term endFieldEndTerm = null, endFieldStartTerm = null;

                if (this.endFieldStartValue != null) {
                    endFieldStartTerm = new Term(this.endFieldName,
                            this.endFieldStartValue);
                }

                if (this.endFieldEndValue != null) {
                    endFieldEndTerm = new Term(this.endFieldName,
                            this.endFieldEndValue);
                }

                RangeQuery query2 = new RangeQuery(endFieldStartTerm,
                        endFieldEndTerm, true);
                booleanQuery.add(query2, BooleanClause.Occur.MUST);
            }

            Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
View Full Code Here

                    if (!endVal.equals("")) {
                        endTerm = new Term(termElem.getElementName(), endVal);
                    }

                    RangeQuery rq = new RangeQuery(startTerm, endTerm,
                            inclusive);
                    booleanQuery.add(rq, BooleanClause.Occur.MUST);
                }
            }
View Full Code Here

            if (!endVal.equals("")) {
                endTerm = new Term(queryCriteria.getElementName(), endVal);
            }

            return new RangeQuery(startTerm, endTerm, inclusive);
        }else {
            throw new CatalogException("Invalid QueryCriteria ["
                    + queryCriteria.getClass().getCanonicalName() + "]");
        }
    }
View Full Code Here

            if (!endVal.equals("")) {
                endTerm = new Term(queryCriteria.getElementName(), endVal);
            }

            return new RangeQuery(startTerm, endTerm, inclusive);
        }else {
            throw new CatalogException("Invalid QueryCriteria ["
                    + queryCriteria.getClass().getCanonicalName() + "]");
        }
    }
View Full Code Here

      // do it as lucene RangeQuery
      Term xLower = new Term(FIELD_NAME, matcher.group(1));
      Term xUpper = new Term(FIELD_NAME, matcher.group(2));

      // inclusive
      RangeQuery rangeQuery = new RangeQuery(xLower, xUpper, true);

      rangeQuery.setBoost(0.0f);                  // trigger filterization
         
      output.add(rangeQuery,
          (c.isProhibited()
              ? BooleanClause.Occur.MUST_NOT
              : (c.isRequired()
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.