From 304836e6759175e9541a9218125f44cf56ca106e Mon Sep 17 00:00:00 2001 From: Joel Bernstein Date: Sun, 9 Sep 2018 20:44:25 -0400 Subject: [PATCH] SOLR-11943: Update RefGuide for latlonVectors and haversineMeters functions. --- solr/solr-ref-guide/src/machine-learning.adoc | 9 +-- solr/solr-ref-guide/src/math-expressions.adoc | 2 +- solr/solr-ref-guide/src/vectorization.adoc | 64 ++++++++++++++++++- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/solr/solr-ref-guide/src/machine-learning.adoc b/solr/solr-ref-guide/src/machine-learning.adoc index ca0ae748540..abbca4b1c10 100644 --- a/solr/solr-ref-guide/src/machine-learning.adoc +++ b/solr/solr-ref-guide/src/machine-learning.adoc @@ -179,10 +179,11 @@ numeric arrays or a *distance matrix* for the columns of a matrix. There are four distance measure functions that return a function that performs the actual distance calculation: -* euclidean() (default) -* manhattan() -* canberra() -* earthMovers() +* euclidean (default) +* manhattan +* canberra +* earthMovers +* haversineMeters (Geospatial distance measure) The distance measure functions can be used with all machine learning functions that support different distance measures. diff --git a/solr/solr-ref-guide/src/math-expressions.adoc b/solr/solr-ref-guide/src/math-expressions.adoc index 27600b6013c..de150cf3ac9 100644 --- a/solr/solr-ref-guide/src/math-expressions.adoc +++ b/solr/solr-ref-guide/src/math-expressions.adoc @@ -38,7 +38,7 @@ record in your Solr Cloud cluster computable. *<>*: Matrix creation, manipulation, and matrix math. -*<>*: Retrieving streams and vectorizing numeric fields. +*<>*: Retrieving streams and vectorizing numeric and lat/long point fields. *<>*: Using math expressions for text analysis and TF-IDF term vectors. diff --git a/solr/solr-ref-guide/src/vectorization.adoc b/solr/solr-ref-guide/src/vectorization.adoc index b01dcc8275e..09b6a0166f6 100644 --- a/solr/solr-ref-guide/src/vectorization.adoc +++ b/solr/solr-ref-guide/src/vectorization.adoc @@ -240,4 +240,66 @@ When this expression is sent to the /stream handler it responds with: ] } } ----- \ No newline at end of file +---- + +== Latitude / Longitude Vectors + +The `latlonVectors` function wraps a list of tuples and parses a lat/long location field into +a matrix of lat/long vectors. Each row in the matrix is a vector that contains the lat/long +pair for the corresponding tuple in the list. The column labels for the matrix are +automatically set to the *id* field in the tuples. The the lat/lon matrix can then be operated +on by machine learning functions using the `haversineMeters` distance measure. + +The `latlonVectors` function takes two parameters: a list of tuples and a named parameter called +*field*. The field parameter tells the `latlonVectors` function which field to parse the lat/lon +vectors from. + +Below is an example of the `latlonVectors`. + +[source,text] +---- +let(a=random(collection1, q="*:*", fl="id, loc_p", rows="5"), + b=latlonVectors(a, field="loc_p")) +---- + +When this expression is sent to the /stream handler it responds with: + +[source,json] +---- +{ + "result-set": { + "docs": [ + { + "b": [ + [ + 42.87183530723629, + 76.74102353397778 + ], + [ + 42.91372904094898, + 76.72874889228416 + ], + [ + 42.911528804897564, + 76.70537292977619 + ], + [ + 42.91143870500213, + 76.74749913047408 + ], + [ + 42.904666267479705, + 76.73933236046092 + ] + ] + }, + { + "EOF": true, + "RESPONSE_TIME": 21 + } + ] + } +} +---- + +