Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final SpanRegexQuery that = (SpanRegexQuery) o;
if (!regexImpl.equals(that.regexImpl)) return false;
if (!term.equals(that.term)) return false;
return true;
|
public java.lang.String | getField()
return term.field();
|
public RegexCapabilities | getRegexImplementation()
return regexImpl;
|
public org.apache.lucene.search.spans.Spans | getSpans(org.apache.lucene.index.IndexReader reader)
throw new UnsupportedOperationException("Query should have been rewritten");
|
public org.apache.lucene.index.Term | getTerm() return term;
|
public java.util.Collection | getTerms()
Collection terms = new ArrayList();
terms.add(term);
return terms;
|
public int | hashCode()
int result;
result = regexImpl.hashCode();
result = 29 * result + term.hashCode();
return result;
|
public org.apache.lucene.search.Query | rewrite(org.apache.lucene.index.IndexReader reader)
RegexQuery orig = new RegexQuery(term);
orig.setRegexImplementation(regexImpl);
// RegexQuery (via MultiTermQuery).rewrite always returns a BooleanQuery
BooleanQuery bq = (BooleanQuery) orig.rewrite(reader);
BooleanClause[] clauses = bq.getClauses();
SpanQuery[] sqs = new SpanQuery[clauses.length];
for (int i = 0; i < clauses.length; i++) {
BooleanClause clause = clauses[i];
// Clauses from RegexQuery.rewrite are always TermQuery's
TermQuery tq = (TermQuery) clause.getQuery();
sqs[i] = new SpanTermQuery(tq.getTerm());
sqs[i].setBoost(tq.getBoost());
}
SpanOrQuery query = new SpanOrQuery(sqs);
query.setBoost(orig.getBoost());
return query;
|
public void | setRegexImplementation(RegexCapabilities impl)
this.regexImpl = impl;
|
public java.lang.String | toString(java.lang.String field)
StringBuffer buffer = new StringBuffer();
buffer.append("spanRegexQuery(");
buffer.append(term);
buffer.append(")");
buffer.append(ToStringUtils.boost(getBoost()));
return buffer.toString();
|