mirror of https://github.com/apache/lucene.git
SOLR-1568: add field queries and range queries to LatLonType
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1003291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa6709517c
commit
7f4c82c0d6
|
@ -84,6 +84,49 @@ public class LatLonType extends AbstractSubTypeFieldType implements SpatialQuery
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) {
|
||||
int dimension = 2;
|
||||
|
||||
String[] p1;
|
||||
String[] p2;
|
||||
try {
|
||||
p1 = DistanceUtils.parsePoint(null, part1, dimension);
|
||||
p2 = DistanceUtils.parsePoint(null, part2, dimension);
|
||||
} catch (InvalidGeoException e) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
|
||||
}
|
||||
BooleanQuery result = new BooleanQuery(true);
|
||||
for (int i = 0; i < dimension; i++) {
|
||||
SchemaField subSF = subField(field, i);
|
||||
// points must currently be ordered... should we support specifying any two opposite corner points?
|
||||
result.add(subSF.getType().getRangeQuery(parser, subSF, p1[i], p2[i], minInclusive, maxInclusive), BooleanClause.Occur.MUST);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query getFieldQuery(QParser parser, SchemaField field, String externalVal) {
|
||||
int dimension = 2;
|
||||
|
||||
String[] p1 = new String[0];
|
||||
try {
|
||||
p1 = DistanceUtils.parsePoint(null, externalVal, dimension);
|
||||
} catch (InvalidGeoException e) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
|
||||
}
|
||||
BooleanQuery bq = new BooleanQuery(true);
|
||||
for (int i = 0; i < dimension; i++) {
|
||||
SchemaField sf = subField(field, i);
|
||||
Query tq = sf.getType().getFieldQuery(parser, sf, p1[i]);
|
||||
bq.add(tq, BooleanClause.Occur.MUST);
|
||||
}
|
||||
return bq;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Query createSpatialQuery(QParser parser, SpatialOptions options) {
|
||||
double[] point = null;
|
||||
|
|
Loading…
Reference in New Issue