Skip to content

Commit a77b029

Browse files
authored
Merge pull request #300 from marklogic/feature/reprocessing-docs-tweak
Added examples of reader/writer for reprocessing docs
2 parents 47ba8ad + 5088dbf commit a77b029

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

docs/reprocess.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Reprocessing Data
44
nav_order: 5
55
---
66

7-
Flux supports reprocessing data already in MarkLogic by using custom code to query for data and custom code to process
7+
Flux supports reprocessing data in MarkLogic by using custom code to query for data and custom code to process
88
retrieved data. Reprocessing data typically involves writing data back to MarkLogic, but you are free to execute any
99
custom code you wish both when querying and processing data.
1010

@@ -26,7 +26,40 @@ A common use case for reprocessing is for the reader to return document URIs, an
2626
on each document URI. However, your reader is free to return any items, and your writer is free to perform any
2727
processing you wish.
2828

29-
For the reader, you must specify one of the following options:
29+
Your reader code must return a sequence, whether implemented [in JavaScript](https://docs.marklogic.com/js/Sequence)
30+
or [in XQuery](https://docs.marklogic.com/guide/xquery/langoverview#id_88685). The following show simple examples
31+
of both:
32+
33+
```
34+
// Return a sequence of URIs in JavaScript.
35+
cts.uris("", null, cts.collectionQuery('example'))
36+
```
37+
38+
```
39+
(: Return a sequence of URIs in XQuery. :)
40+
cts:uris((), (), cts:collection-query('example'))
41+
```
42+
43+
Your writer code will then be invoked once for each item returned by the reader (see below for instructions on sending
44+
a batch of items to the writer). The writer code will be sent a variable named `URI`, though the items do not need to
45+
be URIs. The following show simple examples of JavaScript and XQuery writers (document metadata such as collections
46+
and permissions are omitted for the sake of brevity):
47+
48+
```
49+
// A simple JavaScript writer.
50+
declareUpdate();
51+
var URI;
52+
xdmp.documentInsert(URI, {"example": "document"});
53+
```
54+
55+
```
56+
(: A simple XQuery writer :)
57+
xquery version "1.0-ml";
58+
declare variable $URI external;
59+
xdmp:document-insert($URI, <example>document</example>)
60+
```
61+
62+
To configure the reader, you must specify one of the following options:
3063

3164
| Option | Description|
3265
| --- |---|
@@ -36,7 +69,7 @@ For the reader, you must specify one of the following options:
3669
| `--read-xquery-file` | Path to file containing XQuery code for reading data. |
3770
| `--read-invoke` | Path of a MarkLogic server module to invoke for reading data. |
3871

39-
For the writer, you must specify one of the following options:
72+
To configure the writer, you must specify one of the following options:
4073

4174
| Option | Description|
4275
| --- |---|

0 commit comments

Comments
 (0)