elasticsearch-scroll-stream
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -44,3 +44,3 @@ const { Readable } = require('stream') | ||
body.hits.hits.forEach(hit => { | ||
let ref_results = hit.fields ? hit.fields : hit._source | ||
let ref_results = hit.fields ? hit.fields : hit._source || {} | ||
@@ -47,0 +47,0 @@ // populate extra fields |
{ | ||
"name": "elasticsearch-scroll-stream", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Elasticsearch Scroll query results as a Stream", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -200,2 +200,51 @@ /** | ||
it("Should stream correctly when '_source' property is false", function (done) { | ||
this.timeout(10000) | ||
let counter = 0 | ||
let current_doc | ||
let elasticsearch_client = new Client({ node: 'http://localhost:9200' }) | ||
let es_stream = new ElasticsearchScrollStream( | ||
elasticsearch_client, | ||
{ | ||
index: 'elasticsearch-test-scroll-stream', | ||
type: 'test-type', | ||
scroll: '10s', | ||
size: '50', | ||
_source: false, | ||
body: { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
query_string: { | ||
default_field: '_all', | ||
query: 'name:third*', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
['_id'] | ||
) | ||
es_stream.on('data', function (data) { | ||
expect(es_stream._total).to.equal(20) | ||
current_doc = JSON.parse(data.toString()) | ||
expect(current_doc).to.have.property('_id') | ||
counter++ | ||
}) | ||
es_stream.on('end', function () { | ||
expect(counter).to.equal(20) | ||
done() | ||
}) | ||
es_stream.on('error', function (err) { | ||
done(err) | ||
}) | ||
}) | ||
it('Should throw error when optional_fields is not an array', function (done) { | ||
@@ -202,0 +251,0 @@ let elasticsearch_client = new Client({ node: 'http://localhost:9200' }) |
25191
502