You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jb...@apache.org on 2019/06/14 16:11:07 UTC

[lucene-solr] branch SOLR-13105-visual updated: SOLR-13105: Add vector visualization examples

This is an automated email from the ASF dual-hosted git repository.

jbernste pushed a commit to branch SOLR-13105-visual
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/SOLR-13105-visual by this push:
     new 64da342  SOLR-13105: Add vector visualization examples
64da342 is described below

commit 64da34207983f67826c0f476cc47a53029bb3474
Author: Joel Bernstein <jb...@apache.org>
AuthorDate: Fri Jun 14 12:10:56 2019 -0400

    SOLR-13105: Add vector visualization examples
---
 .../src/images/math-expressions/array.png          | Bin 0 -> 97154 bytes
 .../src/images/math-expressions/bar.png            | Bin 0 -> 126697 bytes
 .../src/images/math-expressions/line1.png          | Bin 0 -> 123755 bytes
 .../src/images/math-expressions/xy.png             | Bin 0 -> 106117 bytes
 solr/solr-ref-guide/src/vector-math.adoc           | 180 +++++++++++++++++++++
 5 files changed, 180 insertions(+)

diff --git a/solr/solr-ref-guide/src/images/math-expressions/array.png b/solr/solr-ref-guide/src/images/math-expressions/array.png
new file mode 100644
index 0000000..23490c6
Binary files /dev/null and b/solr/solr-ref-guide/src/images/math-expressions/array.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/bar.png b/solr/solr-ref-guide/src/images/math-expressions/bar.png
new file mode 100644
index 0000000..ffd102b
Binary files /dev/null and b/solr/solr-ref-guide/src/images/math-expressions/bar.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/line1.png b/solr/solr-ref-guide/src/images/math-expressions/line1.png
new file mode 100644
index 0000000..0d83120
Binary files /dev/null and b/solr/solr-ref-guide/src/images/math-expressions/line1.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/xy.png b/solr/solr-ref-guide/src/images/math-expressions/xy.png
new file mode 100644
index 0000000..a295b85
Binary files /dev/null and b/solr/solr-ref-guide/src/images/math-expressions/xy.png differ
diff --git a/solr/solr-ref-guide/src/vector-math.adoc b/solr/solr-ref-guide/src/vector-math.adoc
index f820ac1..74d51a7 100644
--- a/solr/solr-ref-guide/src/vector-math.adoc
+++ b/solr/solr-ref-guide/src/vector-math.adoc
@@ -52,6 +52,105 @@ When this expression is sent to the `/stream` handler it responds with a JSON ar
 }
 ----
 
+== Visualization
+
+The *zplot* function can be used to visualize vectors using Zeppeling-Solr.
+
+Let's first see what happens when you simply visualize the array function as a table.
+
+image::images/math-expressions/array.png[]
+
+It appears as one row with comma delimeted list of values. You'll find that you can't visualize this using plotting
+tool.
+
+To plot the array you need the zplot function. Let's first look at how zplot output looks like in json output.
+
+[source,text]
+----
+zplot(x=array(1, 2, 3))
+----
+
+When this expression is sent to the `/stream` handler it responds with a JSON array:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "x": 1
+      },
+      {
+        "x": 2
+      },
+      {
+        "x": 3
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 0
+      }
+    ]
+  }
+}
+----
+
+zplot has turned the array into three tulples with the field x.
+
+Let's add another array:
+
+[source,text]
+----
+zplot(x=array(1, 2, 3), y=array(10, 20, 30))
+----
+
+When this expression is sent to the `/stream` handler it responds with a JSON array:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "x": 1,
+        "y": 10
+      },
+      {
+        "x": 2,
+        "y": 20
+      },
+      {
+        "x": 3,
+        "y": 30
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 0
+      }
+    ]
+  }
+}
+----
+
+Now we have three tuples with x and y fields.
+
+Let's see how Zeppelin-Solr handles this output in table format:
+
+image::images/math-expressions/xy.png[]
+
+Now that we have x and y columns defined we can simply switch to one of the line charts
+and plugging in the fields to plot using the chart settings:
+
+image::images/math-expressions/line1.png[]
+
+Each chart has setting which can be explored by clicking on *settings*.
+
+You switch between chart types to for different types of visualizations. Below is an example of
+a bar chart:
+
+image::images/math-expressions/bar.png[]
+
+
 == Array Operations
 
 Arrays can be passed as parameters to functions that operate on arrays.
@@ -178,6 +277,87 @@ When this expression is sent to the `/stream` handler it responds with:
 }
 ----
 
+== Sequences
+
+The *sequence* function can be used to generate a sequence of numbers as an array.
+The example below returns a sequence of 10 numbers, starting from 0, with a step of 2.
+
+[source,text]
+----
+sequence(10, 0, 2)
+----
+
+When this expression is sent to the `/stream` handler it responds with:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "return-value": [
+          0,
+          2,
+          4,
+          6,
+          8,
+          10,
+          12,
+          14,
+          16,
+          18
+        ]
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 7
+      }
+    ]
+  }
+}
+----
+
+The *natural* function can be used to create a sequence of *natural* numbers starting from zero.
+Natural numbers are positive are integers.
+
+The example below creates a sequence starting at zero with natural number up to, but not including
+10.
+
+[source,text]
+----
+natural(10)
+----
+
+When this expression is sent to the `/stream` handler it responds with:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "return-value": [
+          0,
+          1,
+          2,
+          3,
+          4,
+          5,
+          6,
+          7,
+          8,
+          9
+        ]
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 0
+      }
+    ]
+  }
+}
+----
+
 == Vector Sorting
 
 An array can be sorted in natural ascending order with the `asc` function.