Methods Summary |
---|
public org.apache.lucene.search.Query | combine(org.apache.lucene.search.Query[] queries)
return Query.mergeBooleanQueries(queries);
|
public org.apache.lucene.index.Term | getPrefix()Returns the prefix of this query. return prefix;
|
public org.apache.lucene.search.Query | rewrite(org.apache.lucene.index.IndexReader reader)
BooleanQuery query = new BooleanQuery();
TermEnum enumerator = reader.terms(prefix);
try {
String prefixText = prefix.text();
String prefixField = prefix.field();
do {
Term term = enumerator.term();
if (term != null &&
term.text().startsWith(prefixText) &&
term.field() == prefixField) {
TermQuery tq = new TermQuery(term); // found a match
tq.setBoost(getBoost()); // set the boost
query.add(tq, false, false); // add to query
//System.out.println("added " + term);
} 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 (!prefix.field().equals(field)) {
buffer.append(prefix.field());
buffer.append(":");
}
buffer.append(prefix.text());
buffer.append('*");
if (getBoost() != 1.0f) {
buffer.append("^");
buffer.append(Float.toString(getBoost()));
}
return buffer.toString();
|