Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elasticsearch-scroll-stream

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch-scroll-stream - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

6

index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc