Methods Summary |
---|
public org.apache.lucene.search.Query | combine(org.apache.lucene.search.Query[] queries)
return Query.mergeBooleanQueries(queries);
|
public java.lang.String | getField()Returns the field name for this query
return (lowerTerm != null ? lowerTerm.field() : upperTerm.field());
|
public org.apache.lucene.index.Term | getLowerTerm()Returns the lower term of this range query return lowerTerm;
|
public org.apache.lucene.index.Term | getUpperTerm()Returns the upper term of this range query return upperTerm;
|
public boolean | isInclusive()Returns true if the range query is inclusive return inclusive;
|
public org.apache.lucene.search.Query | rewrite(org.apache.lucene.index.IndexReader reader)FIXME: Describe rewrite method here.
BooleanQuery query = new BooleanQuery();
TermEnum enumerator = reader.terms(lowerTerm);
try {
boolean checkLower = false;
if (!inclusive) // make adjustments to set to exclusive
checkLower = true;
String testField = getField();
do {
Term term = enumerator.term();
if (term != null && term.field() == testField) {
if (!checkLower || term.text().compareTo(lowerTerm.text()) > 0) {
checkLower = false;
if (upperTerm != null) {
int compare = upperTerm.text().compareTo(term.text());
/* if beyond the upper term, or is exclusive and
* this is equal to the upper term, break out */
if ((compare < 0) || (!inclusive && compare == 0))
break;
}
TermQuery tq = new TermQuery(term); // found a match
tq.setBoost(getBoost()); // set the boost
query.add(tq, false, false); // add to query
}
}
else {
break;
}
}
while (enumerator.next());
}
finally {
enumerator.close();
}
return query;
|
public java.lang.String | toString(java.lang.String field)Prints a user-readable version of this query.
StringBuffer buffer = new StringBuffer();
if (!getField().equals(field))
{
buffer.append(getField());
buffer.append(":");
}
buffer.append(inclusive ? "[" : "{");
buffer.append(lowerTerm != null ? lowerTerm.text() : "null");
buffer.append(" TO ");
buffer.append(upperTerm != null ? upperTerm.text() : "null");
buffer.append(inclusive ? "]" : "}");
if (getBoost() != 1.0f)
{
buffer.append("^");
buffer.append(Float.toString(getBoost()));
}
return buffer.toString();
|