LUCENE-1713: Some minor fixes and additions to JavaDocs. ConstantScoreRangeQuery is fixed to this mode now.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@791406 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-07-06 07:58:28 +00:00
parent 9689ddf9e8
commit 7acabfecf0
8 changed files with 35 additions and 24 deletions

View File

@ -24,7 +24,6 @@ import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreRangeQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MultiPhraseQuery;
@ -71,7 +70,7 @@ import org.apache.lucene.util.Parameter;
* </p>
*
* <p>
* In {@link RangeQuery}s, QueryParser tries to detect date values, e.g.
* In {@link TermRangeQuery}s, QueryParser tries to detect date values, e.g.
* <tt>date:[6/1/2005 TO 6/4/2005]</tt> produces a range query that searches
* for "date" fields between 2005-06-01 and 2005-06-04. Note that the format
* of the accepted input depends on {@link #setLocale(Locale) the locale}.
@ -1626,6 +1625,12 @@ public class QueryParser implements QueryParserConstants {
finally { jj_save(0, xla); }
}
private boolean jj_3R_3() {
if (jj_scan_token(STAR)) return true;
if (jj_scan_token(COLON)) return true;
return false;
}
private boolean jj_3R_2() {
if (jj_scan_token(TERM)) return true;
if (jj_scan_token(COLON)) return true;
@ -1642,12 +1647,6 @@ public class QueryParser implements QueryParserConstants {
return false;
}
private boolean jj_3R_3() {
if (jj_scan_token(STAR)) return true;
if (jj_scan_token(COLON)) return true;
return false;
}
/** Generated Token Manager. */
public QueryParserTokenManager token_source;
/** Current token. */

View File

@ -48,7 +48,6 @@ import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreRangeQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MultiPhraseQuery;
@ -95,7 +94,7 @@ import org.apache.lucene.util.Parameter;
* </p>
*
* <p>
* In {@link RangeQuery}s, QueryParser tries to detect date values, e.g.
* In {@link TermRangeQuery}s, QueryParser tries to detect date values, e.g.
* <tt>date:[6/1/2005 TO 6/4/2005]</tt> produces a range query that searches
* for "date" fields between 2005-06-01 and 2005-06-04. Note that the format
* of the accepted input depends on {@link #setLocale(Locale) the locale}.

View File

@ -22,7 +22,6 @@ import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreRangeQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MultiPhraseQuery;

View File

@ -21,13 +21,17 @@ import java.text.Collator;
/**
* A range query that returns a constant score equal to its boost for
* all documents in the range.
* <p>
* It does not have an upper bound on the number of clauses covered in the range.
* <p>
* If an endpoint is null, it is said to be "open".
* Either or both endpoints may be open. Open endpoints may not be exclusive
* (you can't select all but the first or last term without explicitly specifying the term to exclude.)
* all documents in the exclusive range of terms.
*
* <p>It does not have an upper bound on the number of clauses covered in the range.
*
* <p>This query matches the documents looking for terms that fall into the
* supplied range according to {@link String#compareTo(String)}. It is not intended
* for numerical ranges, use {@link NumericRangeQuery} instead.
*
* <p>This query is in
* {@linkplain MultiTermQuery#setConstantScoreRewrite(boolean) constant score rewrite mode}.
* If you want to change this, use the new {@link TermRangeQuery} instead.
*
* @deprecated Use {@link TermRangeQuery} for term ranges or
* {@link NumericRangeQuery} for numeric ranges instead.
@ -40,14 +44,14 @@ public class ConstantScoreRangeQuery extends TermRangeQuery
public ConstantScoreRangeQuery(String fieldName, String lowerVal, String upperVal, boolean includeLower, boolean includeUpper)
{
super(fieldName, lowerVal, upperVal, includeLower, includeUpper);
setConstantScoreRewrite(true);
this.constantScoreRewrite = true;
}
public ConstantScoreRangeQuery(String fieldName, String lowerVal,
String upperVal, boolean includeLower,
boolean includeUpper, Collator collator) {
super(fieldName, lowerVal, upperVal, includeLower, includeUpper, collator);
setConstantScoreRewrite(true);
this.constantScoreRewrite = true;
}
public String getLowerVal() {
@ -57,4 +61,10 @@ public class ConstantScoreRangeQuery extends TermRangeQuery
public String getUpperVal() {
return getUpperTerm();
}
/** Changes of mode are not supported by this class (fixed to constant score rewrite mode) */
public void setConstantScoreRewrite(boolean constantScoreRewrite) {
if (!constantScoreRewrite)
throw new UnsupportedOperationException("Use TermRangeQuery instead to enable boolean query rewrite.");
}
}

View File

@ -27,11 +27,12 @@ import org.apache.lucene.index.Term;
* A Query that matches documents within an exclusive range of terms.
*
* <p>This query matches the documents looking for terms that fall into the
* supplied range according to {@link String#compareTo(String)}. It is not intended
* supplied range according to {@link Term#compareTo(Term)}. It is not intended
* for numerical ranges, use {@link NumericRangeQuery} instead.
*
* <p>See {@link MultiTermQuery#setConstantScoreRewrite} for the tradeoffs between
* enabling and disabling constantScoreRewrite mode.
* <p>This query is in
* {@linkplain MultiTermQuery#setConstantScoreRewrite(boolean) boolean query rewrite mode}.
* If you want to change this, use the new {@link TermRangeQuery} instead.
*
* @deprecated Use {@link TermRangeQuery} for term ranges or
* {@link NumericRangeQuery} for numeric ranges instead.

View File

@ -29,6 +29,7 @@ import java.text.Collator;
*
* <p>If you construct a large number of range filters with different ranges but on the
* same field, {@link FieldCacheRangeFilter} may have significantly better performance.
* @since 2.9
*/
public class TermRangeFilter extends MultiTermQueryWrapperFilter {

View File

@ -34,6 +34,7 @@ import org.apache.lucene.util.ToStringUtils;
* <p>This query is in constant score mode per default.
* See {@link MultiTermQuery#setConstantScoreRewrite} for the tradeoffs between
* enabling and disabling constantScoreRewrite mode.
* @since 2.9
*/
public class TermRangeQuery extends MultiTermQuery {
@ -109,7 +110,7 @@ public class TermRangeQuery extends MultiTermQuery {
this.includeLower = includeLower;
this.includeUpper = includeUpper;
this.collator = collator;
setConstantScoreRewrite(true);
this.constantScoreRewrite = true;
}
/** Returns the field name for this query */

View File

@ -29,6 +29,7 @@ import org.apache.lucene.index.Term;
* <p>
* Term enumerations are always ordered by Term.compareTo(). Each term in
* the enumeration is greater than all that precede it.
* @since 2.9
*/
public class TermRangeTermEnum extends FilteredTermEnum {