Skip to content

Commit 13a802d

Browse files
committed
Add installation instruction & syntax highlighting
1 parent 44cc4df commit 13a802d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ It is expected to provide the Elasticsearch reponse's body as a JSON.
1010

1111
See the examples and tests with the official Elasticsearch-js client.
1212

13+
# Installation
14+
15+
```shell
16+
npm install --save elasticsearch-streams
17+
```
18+
1319
# Examples:
1420

1521
## Stream random records into Elasticsearch
16-
```
22+
```js
1723
var WritableBulk = require('elasticsearch-streams').WritableBulk;
1824
var client = new require('elasticsearch').Client();
1925

@@ -38,14 +44,14 @@ https://github.com/joyent/node/issues/5315#issuecomment-16670354
3844

3945
For example to close the ES client as soon as we are done:
4046

41-
```
47+
```js
4248
ws.on('close', function () {
4349
client.close();
4450
});
4551
```
4652

4753
## Stream search results from Elasticsearch
48-
```
54+
```js
4955
var ReadableSearch = require('elasticsearch-streams').ReadableSearch;
5056
var client = new require('elasticsearch').Client();
5157

@@ -72,7 +78,7 @@ rs.pipe(ws).on('close', done);
7278

7379
If we want to start the stream at an offset and define a limit:
7480

75-
```
81+
```js
7682
var offset = 7;
7783
var limit = 21;
7884
var page = 12;
@@ -90,7 +96,7 @@ var searchExec = function searchExec(from, callback) {
9096
```
9197

9298
## Stream scroll/scan results from Elasticsearch
93-
```
99+
```js
94100
var scrollExec = function scrollExec(from, callback) {
95101
if (this.scroll_id) {
96102
return client.scroll({
@@ -116,7 +122,7 @@ rs = new ReadableSearch(scrollExec);
116122
```
117123

118124
## Stream IDs into Elasticsearch multi-get and get documents out.
119-
```
125+
```js
120126
var mgetExec = function(docs, callback) {
121127
client.mget({
122128
index: 'myindex',

0 commit comments

Comments
 (0)