* @return the rewritten query.
* @throws IOException if an error occurs while reading from the index.
*/
@Override
public Query rewrite(IndexReader reader) throws IOException {
Query stdWildcardQuery = new MultiTermQuery() {
protected FilteredTermEnum getEnum(IndexReader reader) throws IOException {
return new WildcardTermEnum(reader, field, tvf, pattern, transform);
}
/** Prints a user-readable version of this query. */
@Override
public String toString(String field) {
StringBuffer buffer = new StringBuffer();
buffer.append(field);
buffer.append(':');
buffer.append(ToStringUtils.boost(getBoost()));
return buffer.toString();
}
};
try {
multiTermQuery = stdWildcardQuery.rewrite(reader);
return multiTermQuery;
} catch (BooleanQuery.TooManyClauses e) {
// MultiTermQuery not possible
log.debug("Too many terms to enumerate, using custom WildcardQuery.");
return this;