lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r1041524 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/src/java/org/apache/solr/schema/LatLonType.java
Date Thu, 02 Dec 2010 18:49:16 GMT
Author: gsingers
Date: Thu Dec  2 18:49:16 2010
New Revision: 1041524

URL: http://svn.apache.org/viewvc?rev=1041524&view=rev
Log:
SOLR-1568: add field queries and range queries to LatLonType [from revision 1003291]

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/schema/LatLonType.java

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/schema/LatLonType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/schema/LatLonType.java?rev=1041524&r1=1041523&r2=1041524&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/schema/LatLonType.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/schema/LatLonType.java Thu
Dec  2 18:49:16 2010
@@ -84,6 +84,49 @@ public class LatLonType extends Abstract
   }
 
 
+  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;
+  }
+
+
+
+
   public Query createSpatialQuery(QParser parser, SpatialOptions options) {
     double[] point = null;
     try {



Mime
View raw message