@@ -10,10 +10,16 @@ It is expected to provide the Elasticsearch reponse's body as a JSON.
10
10
11
11
See the examples and tests with the official Elasticsearch-js client.
12
12
13
+ # Installation
14
+
15
+ ``` shell
16
+ npm install --save elasticsearch-streams
17
+ ```
18
+
13
19
# Examples:
14
20
15
21
## Stream random records into Elasticsearch
16
- ```
22
+ ``` js
17
23
var WritableBulk = require (' elasticsearch-streams' ).WritableBulk ;
18
24
var client = new require (' elasticsearch' ).Client ();
19
25
@@ -38,14 +44,14 @@ https://github.com/joyent/node/issues/5315#issuecomment-16670354
38
44
39
45
For example to close the ES client as soon as we are done:
40
46
41
- ```
47
+ ``` js
42
48
ws .on (' close' , function () {
43
49
client .close ();
44
50
});
45
51
```
46
52
47
53
## Stream search results from Elasticsearch
48
- ```
54
+ ``` js
49
55
var ReadableSearch = require (' elasticsearch-streams' ).ReadableSearch ;
50
56
var client = new require (' elasticsearch' ).Client ();
51
57
@@ -72,7 +78,7 @@ rs.pipe(ws).on('close', done);
72
78
73
79
If we want to start the stream at an offset and define a limit:
74
80
75
- ```
81
+ ``` js
76
82
var offset = 7 ;
77
83
var limit = 21 ;
78
84
var page = 12 ;
@@ -90,7 +96,7 @@ var searchExec = function searchExec(from, callback) {
90
96
```
91
97
92
98
## Stream scroll/scan results from Elasticsearch
93
- ```
99
+ ``` js
94
100
var scrollExec = function scrollExec (from , callback ) {
95
101
if (this .scroll_id ) {
96
102
return client .scroll ({
@@ -116,7 +122,7 @@ rs = new ReadableSearch(scrollExec);
116
122
```
117
123
118
124
## Stream IDs into Elasticsearch multi-get and get documents out.
119
- ```
125
+ ``` js
120
126
var mgetExec = function (docs , callback ) {
121
127
client .mget ({
122
128
index: ' myindex' ,
0 commit comments