lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r1041419 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/src/common/org/apache/solr/common/params/SpatialParams.java solr/src/java/org/apache/solr/search/SpatialFilterQParser.java
Date Thu, 02 Dec 2010 15:49:39 GMT
Author: gsingers
Date: Thu Dec  2 15:49:39 2010
New Revision: 1041419

URL: http://svn.apache.org/viewvc?rev=1041419&view=rev
Log:
SOLR-1568: start backporting Yonik's changes from trunk, one at a time

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/common/org/apache/solr/common/params/SpatialParams.java
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/search/SpatialFilterQParser.java

Modified: lucene/dev/branches/branch_3x/solr/src/common/org/apache/solr/common/params/SpatialParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/common/org/apache/solr/common/params/SpatialParams.java?rev=1041419&r1=1041418&r2=1041419&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/common/org/apache/solr/common/params/SpatialParams.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/common/org/apache/solr/common/params/SpatialParams.java
Thu Dec  2 15:49:39 2010
@@ -24,6 +24,7 @@ package org.apache.solr.common.params;
 public interface SpatialParams {
   public static final String POINT = "pt";
   public static final String DISTANCE = "d";
+  public static final String FIELD = "sfield";  // the field that contains the points we
are measuring from "pt"
   /**
    * km - kilometers
    * mi - miles

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/search/SpatialFilterQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/search/SpatialFilterQParser.java?rev=1041419&r1=1041418&r2=1041419&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/search/SpatialFilterQParser.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/search/SpatialFilterQParser.java
Thu Dec  2 15:49:39 2010
@@ -67,25 +67,31 @@ public class SpatialFilterQParser extend
     //TODO: Should we accept multiple fields
     String[] fields = localParams.getParams(CommonParams.FL);
     if (fields == null || fields.length == 0) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, CommonParams.FL + " is
not properly specified");
+      String field = getParam(SpatialParams.FIELD);
+      if (field == null)
+        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, " missing field for
spatial request");
+      fields = new String[] {field};
     }
-    String pointStr = params.get(SpatialParams.POINT);
+    
+    String pointStr = getParam(SpatialParams.POINT);
     if (pointStr == null) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, SpatialParams.POINT +
" is not properly specified");
     }
 
-    double dist = params.getDouble(SpatialParams.DISTANCE, -1);
+    double dist = -1;
+    String distS = getParam(SpatialParams.DISTANCE);
+    if (distS != null) dist = Double.parseDouble(distS);
+
     if (dist < 0) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, SpatialParams.DISTANCE
+ " must be >= 0");
     }
-    IndexSchema schema = req.getSchema();
 
     String measStr = localParams.get(SpatialParams.MEASURE);
     //TODO: Need to do something with Measures
     Query result = null;
     //fields is valid at this point
     if (fields.length == 1) {
-      SchemaField sf = schema.getField(fields[0]);
+      SchemaField sf = req.getSchema().getField(fields[0]);
       FieldType type = sf.getType();
 
       if (type instanceof SpatialQueryable) {



Mime
View raw message