DistanceQuerypublic class DistanceQuery extends ComposedQuery implements DistanceSubQueryCopyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. |
Fields Summary |
---|
private int | opDistance | private boolean | ordered |
Constructors Summary |
---|
public DistanceQuery(List queries, boolean infix, int opDistance, String opName, boolean ordered)
super(queries, infix, opName);
this.opDistance = opDistance; /* the distance indicated in the operator */
this.ordered = ordered;
|
Methods Summary |
---|
public void | addSpanQueries(SpanNearClauseFactory sncf)
Query snq = getSpanNearQuery(sncf.getIndexReader(),
sncf.getFieldName(),
getWeight(),
sncf.getBasicQueryFactory());
sncf.addSpanNearQuery(snq);
| public java.lang.String | distanceSubQueryNotAllowed()
Iterator sqi = getSubQueriesIterator();
while (sqi.hasNext()) {
Object leq = sqi.next();
if (leq instanceof DistanceSubQuery) {
DistanceSubQuery dsq = (DistanceSubQuery) leq;
String m = dsq.distanceSubQueryNotAllowed();
if (m != null) {
return m;
}
} else {
return "Operator " + getOperatorName() + " does not allow subquery " + leq.toString();
}
}
return null; /* subqueries acceptable */
| public int | getOpDistance()return opDistance;
| public org.apache.lucene.search.Query | getSpanNearQuery(org.apache.lucene.index.IndexReader reader, java.lang.String fieldName, float boost, BasicQueryFactory qf)
SpanQuery[] spanNearClauses = new SpanQuery[getNrSubQueries()];
Iterator sqi = getSubQueriesIterator();
int qi = 0;
while (sqi.hasNext()) {
SpanNearClauseFactory sncf = new SpanNearClauseFactory(reader, fieldName, qf);
((DistanceSubQuery)sqi.next()).addSpanQueries(sncf);
if (sncf.size() == 0) { /* distance operator requires all sub queries */
while (sqi.hasNext()) { /* produce evt. error messages but ignore results */
((DistanceSubQuery)sqi.next()).addSpanQueries(sncf);
sncf.clear();
}
return SrndQuery.theEmptyLcnQuery;
}
spanNearClauses[qi] = sncf.makeSpanNearClause();
qi++;
}
SpanNearQuery r = new SpanNearQuery(spanNearClauses, getOpDistance() - 1, subQueriesOrdered());
r.setBoost(boost);
return r;
| public org.apache.lucene.search.Query | makeLuceneQueryFieldNoBoost(java.lang.String fieldName, BasicQueryFactory qf)
return new Query () {
public String toString(String fn) {
return getClass().toString() + " " + fieldName + " (" + fn + "?)";
}
public Query rewrite(IndexReader reader) throws IOException {
return getSpanNearQuery(reader, fieldName, getBoost(), qf);
}
};
| public boolean | subQueriesOrdered()return ordered;
|
|