Socket
Socket
Sign inDemoInstall

elastic-full-search

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-full-search - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/ElasticClientManager.js

6

index.js

@@ -5,3 +5,7 @@ 'use strict';

fullSearch: require('./lib/fullSearch'),
fullSearchStream: require('./lib/fullSearchStream')
fullSearchStream: require('./lib/fullSearchStream'),
ElasticClientManager: require('./lib/ElasticClientManager'),
fullSearchRaw: require('./lib/fullSearchRaw'),
fullSearchStreamRaw: require('./lib/fullSearchStreamRaw')
};

5

lib/fullSearchStream.js

@@ -6,3 +6,4 @@ 'use strict';

/**
* Perform a full search using the scroll feature and returns a stream.Readable instance.
* Perform a full search using the scroll feature and returns a stream.Readable instance
* in object mode.
*

@@ -12,3 +13,3 @@ * @param {Object} elasticClient The elastic client.

* @param {String} scroll The scroll value ex: '30s'.
* @return {stream.Readable} A readable stream.
* @return {stream.Readable} A readable stream in object mode.
*/

@@ -15,0 +16,0 @@ function fullSearchStream(elasticClient, params, scroll) {

{
"name": "elastic-full-search",
"description": "Functions to get full results from elasticsearch searches.",
"version": "1.0.0",
"version": "1.1.0",
"author": "Alejandro Santiago Nieto",
"license": "MIT",
"dependencies": {
"fast-json": "1.x.x",
"utjs": "2.x.x"

@@ -9,0 +10,0 @@ },

elastic-full-search
===
Functions to get full results from elasticsearch searches.
* searchFull: Returns the full result as an array in a single callback.
* searchFullStream: Returns a stream.Readable instance connected to the full result.
* **searchFull**: Returns the full result as an array in a single callback.
* **searchFullStream**: Returns a stream.Readable instance in **object mode** connected to the full result.
* **searchFullRaw**: Returns the full result as a string (no JSON.parse() inside) in a single callback.
* **searchFullStreamRaw**: Returns a stream.Readable instance in **buffer mode** (no JSON.parse() inside) connected to the full result.
> In order to use *searchFullRaw* and *searchFullStreamRaw*, the elasticsearch client need to be modified as explain in the secction *raw methods*.
## Install
npm install elastic-full-search
## Usage

@@ -35,3 +40,3 @@ ```javascript

// Gets everything streamed through the readableStream.
// Gets everything streamed through the readableStream in object mode.
var readableStream = fullSearchStream(elasticClient, params, scroll);

@@ -43,2 +48,45 @@ readableStream.on('data', (docs) => {

readableStream.on('end', () => console.log('Stream ended'));
```
```
## Raw methods
With a small change in the elasticsearch client using reflection, we can get adventage of a better performance and throughput removing unnecessaries *JSON.parse()* calls and using streams in **buffer mode** (the default stream mode).
## Usage
```javascript
const elasticsearch = require('elasticsearch');
const elasticClient = new elasticsearch.Client({
host: 'localhost:9200',
log: 'warning'
});
const fullSearchRaw = require('../lib/fullSearchRaw');
const fullSearchStreamRaw = require('../lib/fullSearchStreamRaw');
const ElasticClientManager = require('../lib/ElasticClientManager');
// Responses will now be Strings instead of JSON objects
ElasticClientManager.elasticClientToRawResponses(elasticClient);
var params = {
index: 'myindex',
type: 'mytype',
body: { query: { match_all: {} } },
size: 250 // Max. documents per shard
};
var scroll = '30s';
// Gets everything as a JSON string in "docsString"
fullSearchRaw(elasticClient, params, scroll, (err, docsString) => {
if (err) { return console.error(err); }
// Do something with "docsString"
});
// Gets everything streamed through the readableStream.
var readableStream = fullSearchStreamRaw(elasticClient, params, scroll);
readableStream.on('data', (docsBuff) => {
// Do something with "docsBuff"
});
readableStream.on('error', (err) => console.error(err));
readableStream.on('end', () => console.log('Stream ended'));
```
Check out the folder *example* for more examples.
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