@@ -37,10 +37,10 @@ The simplest spath is to extract a single field. This extracts `n` from the `doc
3737
3838PPL query::
3939
40- PPL > source=test_spath | spath input=doc n;
40+ os > source=structured | spath input=doc_n n | fields doc_n n;
4141 fetched rows / total rows = 3/3
4242 +----------+---+
43- | doc | n |
43+ | doc_n | n |
4444 |----------+---|
4545 | {"n": 1} | 1 |
4646 | {"n": 2} | 2 |
@@ -54,10 +54,10 @@ These queries demonstrate more JSON path uses, like traversing nested fields and
5454
5555PPL query::
5656
57- PPL > source=test_spath | spath input=doc output=first_element list{0} | spath input=doc output=all_elements list{} | spath input=doc output=nested nest_out.nest_in;
57+ os > source=structured | spath input=doc_list output=first_element list{0} | spath input=doc_list output=all_elements list{} | spath input=doc_list output=nested nest_out.nest_in | fields doc_list first_element all_elements nested ;
5858 fetched rows / total rows = 3/3
5959 +------------------------------------------------------+---------------+--------------+--------+
60- | doc | first_element | all_elements | nested |
60+ | doc_list | first_element | all_elements | nested |
6161 |------------------------------------------------------+---------------+--------------+--------|
6262 | {"list": [1, 2, 3, 4], "nest_out": {"nest_in": "a"}} | 1 | [1,2,3,4] | a |
6363 | {"list": [], "nest_out": {"nest_in": "a"}} | null | [] | a |
@@ -71,10 +71,27 @@ The example shows extracting an inner field and doing statistics on it, using th
7171
7272PPL query::
7373
74- PPL > source=test_spath | spath input=doc n | eval n=cast(n as int) | stats sum(n);
74+ os > source=structured | spath input=doc_n n | eval n=cast(n as int) | stats sum(n) | fields `sum(n)` ;
7575 fetched rows / total rows = 1/1
7676 +--------+
7777 | sum(n) |
7878 |--------|
7979 | 6 |
8080 +--------+
81+
82+ Example 4: Escaped paths
83+ ============================
84+
85+ `spath ` can escape paths with strings to accept any path that `json_extract ` does. This includes escaping complex field names as array components.
86+
87+ PPL query::
88+
89+ os> source=structured | spath output=a input=doc_escape "['a fancy field name']" | spath output=b input=doc_escape "['a.b.c']" | fields a b;
90+ fetched rows / total rows = 3/3
91+ +-------+---+
92+ | a | b |
93+ |-------+---|
94+ | true | 0 |
95+ | true | 1 |
96+ | false | 2 |
97+ +-------+---+
0 commit comments