Apache Lucene open-source search software
SOLR-11943: Change location... to latlon...
Joel Bernsteinf5ce384fb8e0
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.javaindex 9568ecb7c95..3f24e7bbb9a 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java@@ -255,7 +255,7 @@ public class Lang {.withFunctionName("removeCache", RemoveCacheEvaluator.class).withFunctionName("listCache", ListCacheEvaluator.class).withFunctionName("zscores", NormalizeEvaluator.class)- .withFunctionName("locationVectors", LocationVectorsEvaluator.class)+ .withFunctionName("latlonVectors", LatLonVectorsEvaluator.class)// Boolean Stream Evaluatorsdiff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LocationVectorsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LatLonVectorsEvaluator.javasimilarity index 76%rename from solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LocationVectorsEvaluator.javarename to solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LatLonVectorsEvaluator.javaindex 0c1ba99c5ea..de8168a127c 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LocationVectorsEvaluator.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LatLonVectorsEvaluator.java@@ -26,12 +26,22 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter;import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;-public class LocationVectorsEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker {+/**+ * The LatLonVectorsEvaluator maps to the latlonVectors Math Expression. The latlonVectors expression+ * takes a list of Tuples that contain a lat,lon point field and a named parameter called field+ * as input. The field parameter specifies which field to parse the lat,lon vectors from in the Tuples.+ *+ * The latlonVectors function returns a matrix of lat,lon vectors. Each row in the matrix+ * contains a single lat,lon pair.+ *+ **/++public class LatLonVectorsEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker {protected static final long serialVersionUID = 1L;private String field;- public LocationVectorsEvaluator(StreamExpression expression, StreamFactory factory) throws IOException {+ public LatLonVectorsEvaluator(StreamExpression expression, StreamFactory factory) throws IOException {super(expression, factory);List<StreamExpressionNamedParameter> namedParams = factory.getNamedOperands(expression);@@ -45,7 +55,7 @@ public class LocationVectorsEvaluator extends RecursiveObjectEvaluator implement}if(field == null) {- throw new IOException("The named parameter \"field\" must be set for the locationVectors function.");+ throw new IOException("The named parameter \"field\" must be set for the latlonVectors function.");}}@@ -55,13 +65,13 @@ public class LocationVectorsEvaluator extends RecursiveObjectEvaluator implementif (objects.length == 1) {//Just docsif(!(objects[0] instanceof List)) {- throw new IOException("The locationVectors function expects a list of Tuples as a parameter.");+ throw new IOException("The latlonVectors function expects a list of Tuples as a parameter.");} else {List list = (List)objects[0];if(list.size() > 0) {Object o = list.get(0);if(!(o instanceof Tuple)) {- throw new IOException("The locationVectors function expects a list of Tuples as a parameter.");+ throw new IOException("The latlonVectors function expects a list of Tuples as a parameter.");}} else {throw new IOException("Empty list was passed as a parameter to termVectors function.");@@ -73,7 +83,7 @@ public class LocationVectorsEvaluator extends RecursiveObjectEvaluator implementdouble[][] locationVectors = new double[tuples.size()][2];List<String> features = new ArrayList();features.add("lat");- features.add("long");+ features.add("lon");List<String> rowLabels = new ArrayList();@@ -99,7 +109,7 @@ public class LocationVectorsEvaluator extends RecursiveObjectEvaluator implementmatrix.setRowLabels(rowLabels);return matrix;} else {- throw new IOException("The termVectors function takes a single positional parameter.");+ throw new IOException("The latlonVectors function takes a single positional parameter.");}}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/TestLang.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/TestLang.javaindex ee8c1e1beb3..12ff2e945f4 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/TestLang.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/TestLang.java@@ -70,7 +70,7 @@ public class TestLang extends LuceneTestCase {"mod", "ceil", "floor", "sin", "asin", "sinh", "cos", "acos", "cosh", "tan", "atan", "tanh", "round", "sqrt","cbrt", "coalesce", "uuid", "if", "convert", "valueAt", "memset", "fft", "ifft", "euclidean","manhattan","earthMovers", "canberra", "chebyshev", "ones", "zeros", "setValue", "getValue", "knnRegress", "gaussfit",- "outliers", "stream", "getCache", "putCache", "listCache", "removeCache", "zscores", "locationVectors"};+ "outliers", "stream", "getCache", "putCache", "listCache", "removeCache", "zscores", "latlonVectors"};@Testpublic void testLang() {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.javaindex 4bcf50d1859..137add6a039 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java@@ -312,7 +312,7 @@ public class MathExpressionTest extends SolrCloudTestCase {}@Test- public void testLocationFunctions() throws Exception {+ public void testLatlonFunctions() throws Exception {UpdateRequest updateRequest = new UpdateRequest();int i=0;@@ -326,7 +326,7 @@ public class MathExpressionTest extends SolrCloudTestCase {String expr = "let(echo=true," +" a=search("+COLLECTIONORALIAS+", q=*:*, fl=\"id, loc_p, price_i\",rows=100, sort=\"price_i asc\"),"+- " b=locationVectors(a, field=loc_p)," ++ " b=latlonVectors(a, field=loc_p)," +" c=distance(array(40.7128, 74.0060), array(45.7128, 74.0060), haversineMeters()))";