From 01397c1b88883593d741e2c744d316dc033a995a Mon Sep 17 00:00:00 2001 From: Joel Bernstein Date: Thu, 8 Nov 2018 15:29:15 -0500 Subject: [PATCH] SOLR-12913: Add ltrim and rtrim to the Math Expressions User Guide --- solr/solr-ref-guide/src/vector-math.adoc | 35 ++++++++++++++++++++++ solr/solr-ref-guide/src/vectorization.adoc | 8 ++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/solr/solr-ref-guide/src/vector-math.adoc b/solr/solr-ref-guide/src/vector-math.adoc index 6171d77e9dc..cb4ef1d8058 100644 --- a/solr/solr-ref-guide/src/vector-math.adoc +++ b/solr/solr-ref-guide/src/vector-math.adoc @@ -143,6 +143,41 @@ When this expression is sent to the `/stream` handler it responds with: } ---- +Elements of an array can be trimmed using the `ltrim` (left trim) and `rtrim` (right trim) functions. +The `ltrim` and `rtrim` functions remove a specific number of elements from the left or right of an array. + +The example below shows the `lrtim` function trimming the first 2 elements of an array: + +[source,text] +---- +ltrim(array(0,1,2,3,4,5,6)) +---- + +When this expression is sent to the `/stream` handler it responds with: + +[source,json] +---- +{ + "result-set": { + "docs": [ + { + "return-value": [ + 2, + 3, + 4, + 5, + 6, + ] + }, + { + "EOF": true, + "RESPONSE_TIME": 1 + } + ] + } +} +---- + == Vector Sorting An array can be sorted in natural ascending order with the `asc` function. diff --git a/solr/solr-ref-guide/src/vectorization.adoc b/solr/solr-ref-guide/src/vectorization.adoc index 9483cc38c61..5c08a586c59 100644 --- a/solr/solr-ref-guide/src/vectorization.adoc +++ b/solr/solr-ref-guide/src/vectorization.adoc @@ -250,15 +250,15 @@ When this expression is sent to the `/stream` handler it responds with: == Facet Co-occurrence Matrices -The `facet` function can be used to quickly perform mulit-dimension aggregations of categorical data from +The `facet` function can be used to quickly perform multi-dimension aggregations of categorical data from records stored in a Solr Cloud collection. These multi-dimension aggregations can represent co-occurrence counts for the values in the dimensions. The `pivot` function can be used to move two dimensional aggregations into a co-occurrence matrix. The co-occurrence matrix can then be clustered or analyzed for correlations to learn about the hidden connections within the data. -In the example below th `facet` expression is used to generate a two dimensional faceted aggregation. +In the example below the `facet` expression is used to generate a two dimensional faceted aggregation. The first dimension is the US State that a car was purchased in and the second dimension is the car model. -The two dimensional facet generates the co-occurrence counts for the number of times a particular car model +This two dimensional facet generates the co-occurrence counts for the number of times a particular car model was purchased in a particular state. @@ -311,7 +311,7 @@ When this expression is sent to the `/stream` handler it responds with: The `pivot` function can be used to move the facet results into a co-occurrence matrix. In the example below The `pivot` function is used to create a matrix where the rows of the matrix are the US States (state) and the columns of the matrix are the car models (model). The values in the matrix are the co-occurrence counts (count(*)) - from facet results. Once the co-occurrence matrix has been created the US States can be clustered + from the facet results. Once the co-occurrence matrix has been created the US States can be clustered by car model, or the matrix can be transposed and car models can be clustered by the US States where they were bought.