Skip to content

Commit 63df947

Browse files
committed
Enhanced docs on reading data with example of using CTS API
1 parent 220a532 commit 63df947

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

docs/reading.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,31 @@ df = spark.read.format("com.marklogic.spark") \
2020
.load()
2121
```
2222

23-
As shown above, `format`, `spark.marklogic.client.uri` (or the other `spark.marklogic.client` options
23+
As demonstrated above, `format`, `spark.marklogic.client.uri` (or the other `spark.marklogic.client` options
2424
that can be used to define the connection details), and `spark.marklogic.read.opticQuery` are required. The
25-
following sections provide more details about these and other options that can be set.
25+
sections below provide more detail about these and other options that can be set.
26+
27+
Your Optic query can include any of the
28+
[different kinds of Optic operations](https://docs.marklogic.com/guide/app-dev/OpticAPI#id_35559) that MarkLogic
29+
supports. For example, the following demonstrates how the
30+
[powerful MarkLogic CTS API](https://docs.marklogic.com/guide/search-dev/cts_query) can be easily used within an
31+
Optic query to constrain the returned rows based on a search query (note that the JavaScript CTS API must be used in
32+
the Optic query):
33+
34+
```
35+
query = "op.fromView('example', 'employee').where(cts.wordQuery('Drive'))"
36+
37+
df = spark.read.format("com.marklogic.spark") \
38+
.option("spark.marklogic.client.uri", "spark-example-user:password@localhost:8020") \
39+
.option("spark.marklogic.read.opticQuery", query) \
40+
.load()
41+
```
42+
43+
The `where` clause in the example above can include any of the query features supported by MarkLogic, such as
44+
[geospatial queries](https://docs.marklogic.com/guide/search-dev/geospatial),
45+
[wildcard queries](https://docs.marklogic.com/guide/search-dev/wildcard), and
46+
query expansion via [a thesaurus](https://docs.marklogic.com/guide/search-dev/thesaurus) or
47+
[spelling correction](https://docs.marklogic.com/guide/search-dev/spelling).
2648

2749
## Optic query requirements
2850

0 commit comments

Comments
 (0)