elasticsearch-scroll-stream
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -16,3 +16,3 @@ /** | ||
* @param `optional_fields` - array of optional properties to include in the results. | ||
* Allowed values: '_id', '_score', '_type', '_index' | ||
* Allowed values: '_id', '_score', '_type', '_index', '_parent', '_routing' | ||
* @param `stream_opts` - object to be passed to ReadableStream | ||
@@ -27,3 +27,3 @@ */ | ||
var allowed_extrafields = ['_id', '_score', '_type', '_index']; | ||
var allowed_extrafields = ['_id', '_score', '_type', '_index', '_parent', '_routing']; | ||
optional_fields.forEach(function(entry) { | ||
@@ -33,3 +33,3 @@ if (allowed_extrafields.indexOf(entry) == -1) { | ||
} | ||
}); | ||
}); | ||
@@ -36,0 +36,0 @@ stream_opts = (!!stream_opts) ? stream_opts : {}; |
@@ -18,3 +18,3 @@ /** | ||
* @param `optional_fields` - array of optional properties to include in the results. | ||
* Allowed values: '_id', '_score', '_type', '_index' | ||
* Allowed values: '_id', '_score', '_type', '_index', '_parent', '_routing' | ||
* @param `stream_opts` - object to be passed to ReadableStream | ||
@@ -77,2 +77,6 @@ */ | ||
} else { | ||
// trigger an asyncronous clearScroll for the current _scroll_id | ||
self._client.clearScroll({ scrollId: response._scroll_id }, function(err, res) {}); | ||
// end correctly | ||
return setImmediate(function() { | ||
@@ -79,0 +83,0 @@ self._reading = false; |
{ | ||
"name": "elasticsearch-scroll-stream", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Elasticsearch Scroll query results as a Stream", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -13,8 +13,9 @@ /** | ||
it.skip('[DEPRECATED Lib Elastical]: stream data correctly from elasticsearch', function(done) { | ||
it("Should stream correctly when '_source' property is specified", function(done) { | ||
this.timeout(10000); | ||
var counter = 0; | ||
var current_doc; | ||
var elastical_client = new elastical.Client(); | ||
var elasticsearch_client = new elasticsearch.Client(); | ||
var es_stream = new ElasticsearchScrollStream(elastical_client, { | ||
var es_stream = new ElasticsearchScrollStream(elasticsearch_client, { | ||
index: 'elasticsearch-test-scroll-stream', | ||
@@ -24,13 +25,15 @@ type: 'test-type', | ||
size: '50', | ||
_source: ['name'], | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
query_string: { | ||
default_field: "_all", | ||
query: 'name:second*' | ||
_source: ["name"], | ||
body: { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
query_string: { | ||
default_field: "_all", | ||
query: 'name:third*' | ||
} | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
@@ -41,4 +44,5 @@ } | ||
es_stream.on('data', function(data) { | ||
expect(es_stream._total).to.equal(20); | ||
current_doc = JSON.parse(data.toString()); | ||
expect(current_doc.name).to.equal("second chunk name"); | ||
expect(current_doc.name).to.equal("third chunk name"); | ||
counter++; | ||
@@ -58,5 +62,4 @@ }); | ||
it("Should stream correctly when '_source' property is specified", function(done) { | ||
it("Should explicitly clear the active search context when the scroll finishes", function(done) { | ||
this.timeout(10000); | ||
var counter = 0; | ||
var current_doc; | ||
@@ -88,11 +91,14 @@ var elasticsearch_client = new elasticsearch.Client(); | ||
es_stream.on('data', function(data) { | ||
expect(es_stream._total).to.equal(20); | ||
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(); | ||
elasticsearch_client.indices.stats({ | ||
index: '_all', | ||
metric: 'search' | ||
}, function(err, res) { | ||
expect(res._all.total.search.open_contexts).to.equal(0); | ||
done(); | ||
}); | ||
}); | ||
@@ -99,0 +105,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24840
477