elasticsearch-scroll-stream
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -45,3 +45,8 @@ /** | ||
response.hits.hits.forEach(function(hit) { | ||
self.push(JSON.stringify(hit.fields)); | ||
if(hit.fields) { | ||
self.push(JSON.stringify(hit.fields)); | ||
} else { | ||
self.push(JSON.stringify(hit._source)); | ||
} | ||
self._counter++; | ||
@@ -48,0 +53,0 @@ }); |
{ | ||
"name": "elasticsearch-scroll-stream", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Elasticsearch Scroll query results as a Stream", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -126,3 +126,3 @@ | ||
Copyright (c) 2014 Francesco Valente | ||
Copyright (c) 2016 Francesco Valente | ||
@@ -129,0 +129,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -56,3 +56,3 @@ /** | ||
it('Lib Elasticsearch: should stream data correctly from elasticsearch', function(done) { | ||
it('Lib Elasticsearch: should stream data correctly when fields are specified', function(done) { | ||
this.timeout(10000); | ||
@@ -100,3 +100,47 @@ var counter = 0; | ||
}); | ||
it('Lib Elasticsearch: should stream data correctly when no fields are specified (full _source)', function(done) { | ||
this.timeout(10000); | ||
var counter = 0; | ||
var current_doc; | ||
var elasticsearch_client = new elasticsearch.Client(); | ||
var es_stream = new ElasticsearchScrollStream(elasticsearch_client, { | ||
index: 'elasticsearch-test-scroll-stream', | ||
type: 'test-type', | ||
scroll: '10s', | ||
size: '50', | ||
body: { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
query_string: { | ||
default_field: "_all", | ||
query: 'name:third*' | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}); | ||
es_stream.on('data', function(data) { | ||
current_doc = JSON.parse(data.toString()); | ||
expect(current_doc.name).to.equal("third chunk name"); | ||
counter++; | ||
}); | ||
es_stream.on('end', function() { | ||
expect(counter).to.equal(20); | ||
done(); | ||
}); | ||
es_stream.on('error', function(err) { | ||
done(err); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
15210
261