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

elasticsearch

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

4

index.js

@@ -17,3 +17,3 @@ var

// let the magic begin
function createClient (options, requestLogger) {
function createClient (options) {
'use strict';

@@ -37,3 +37,3 @@

(options.request || require('./lib/request'))
.initialize(options.server, requestLogger),
.initialize(options.server),
client = core(options, request);

@@ -40,0 +40,0 @@

@@ -64,2 +64,3 @@ var utils = require('./utils');

var
action = {},
commands = [],

@@ -70,3 +71,3 @@ index = utils.getIndexSyntax(options, config),

documents.forEach(function (document) {
commands.push({
action = {
index : {

@@ -76,3 +77,11 @@ _index : index,

}
});
};
// fix for issue #28, ability to handle _id property on document
if (document.hasOwnProperty('_id')) {
action.index._id = document._id;
delete document._id;
}
commands.push(action);
commands.push(document);

@@ -494,2 +503,24 @@ });

// http://www.elasticsearch.org/guide/reference/api/search/term-suggest/
// fix for issue #29
self.suggest = function (options, query, callback) {
if (!callback && typeof query === 'function') {
callback = query;
query = options;
options = {};
}
var
index = utils.getIndexSyntax(options, config),
type = utils.getTypeSyntax(options, config);
options.query = utils.exclude(options, paramExcludes);
options.pathname = utils.pathAppend(index) +
utils.pathAppend(type) +
utils.pathAppend('_suggest');
return req.post(options, query, callback);
};
// http://www.elasticsearch.org/guide/reference/api/percolate/

@@ -496,0 +527,0 @@ self.unregisterPercolator = function (options, callback) {

var
events = require('events'),
http = require('http'),

@@ -6,3 +7,4 @@ https = require('https'),

DEFAULT_TIMEOUT = 30000;
DEFAULT_TIMEOUT = 30000,
EVENT_REQUEST = 'request';

@@ -14,6 +16,6 @@

*/
exports.initialize = function (settings, logger, self) {
exports.initialize = function (settings, self) {
'use strict';
self = self || {};
self = self || Object.create(events.EventEmitter.prototype);
self.failover = {

@@ -27,2 +29,5 @@ count : 0,

// enable events on request
events.EventEmitter.call(self);
/*

@@ -65,5 +70,5 @@ If failover information is provided, store the options for use

// issue #23 - ability to log http(s) requests
if (logger) {
logger(options);
// issue #23 - ability to log http(s) requests (emit an event update)
if (self.emit) {
self.emit(EVENT_REQUEST, options);
}

@@ -70,0 +75,0 @@

@@ -5,3 +5,3 @@ {

"main" : "index.js",
"version" : "0.3.10",
"version" : "0.3.11",
"author" : "Nick Campbell (http://github.com/ncb000gt)",

@@ -32,5 +32,5 @@ "contributors" : [

"coveralls": "~2.0.16",
"jscoverage": "~0.3.7",
"jshint": "~2.1.4",
"mocha": "~1.12.0",
"jscoverage": "~0.3.8",
"jshint": "~2.1.10",
"mocha": "~1.12.1",
"mocha-lcov-reporter": "0.0.1",

@@ -37,0 +37,0 @@ "stact": "~0.0.11"

@@ -50,10 +50,2 @@ # node-elasticsearch

You may also supply a logger for each request by passing in an optional second argument to `elasticsearch.createClient(config, requestLogger)`. This will result in every http(s) request being logged via the callback supplied to the `requestLogger` parameter.
```Javascript
var
elasticsearch = require('elasticsearch'),
es = elasticsearch.createClient(config, console.log);
```
##### config._index

@@ -169,2 +161,28 @@

#### request event
An event named `request` with a signature of `function (options) { }` is emitted for each API call.
```Javascript
var elasticsearch = require('elasticsearch');
var config = {
_index : 'bawss',
server : {
hosts : ['localhost:9200', 'localhost:9201', 'localhost:9202']
}
};
var es = elasticsearch(config);
es.request.on('request', function (options) {
console.log('request initiated');
console.log(options);
});
es.count(function (err, results) {
// event results in request options being logged to console...
});
```
#### options for any operation

@@ -171,0 +189,0 @@

@@ -30,2 +30,3 @@ var stubMethod = function (method, options, data, callback) {

global.clientOptions = {};

@@ -32,0 +33,0 @@ global.req = require('../lib/request').initialize({});

@@ -6,2 +6,5 @@ var

describe('Functional: cluster', function () {
// upping default timeout for Travis-CI builds
this.timeout(4000);
var

@@ -12,3 +15,4 @@ index = 'elasticsearch_test_functional_cluster_' + Date.now(),

before(function (done) {
client = createClient({_index: index});
clientOptions._index = index;
client = createClient(clientOptions);
client.indices.createIndex(function (err) {

@@ -15,0 +19,0 @@ assert.ifError(err);

@@ -6,2 +6,5 @@ var

describe('Functional: core', function () {
// upping default timeout for Travis-CI builds
this.timeout(4000);
var

@@ -12,3 +15,4 @@ index = 'elasticsearch_test_functional_core_' + Date.now(),

before(function (done) {
client = createClient({_index: index});
clientOptions._index = index;
client = createClient(clientOptions);
client.indices.createIndex(function (err) {

@@ -324,2 +328,18 @@ assert.ifError(err);

describe('#suggest', function () {
it('works', function (done) {
client.suggest({'test-suggest-1': {text: 'noed', term: {field: 'title'}}}, function (err, result) {
assert.ifError(err);
assert.ok(result['test-suggest-1']);
client.suggest({'test-suggest-2': {text: 'noed', term: {field: 'summary'}}}, function (err, result) {
assert.ifError(err);
assert.ok(result['test-suggest-2']);
done();
});
});
});
});
describe('#update', function () {

@@ -326,0 +346,0 @@ it('works', function (done) {

@@ -6,2 +6,5 @@ var

describe('Functional: indices', function () {
// upping default timeout for Travis-CI builds
this.timeout(4000);
var

@@ -12,3 +15,4 @@ index = 'elasticsearch_test_functional_indices_' + Date.now(),

before(function (done) {
client = createClient({_index: index});
clientOptions._index = index;
client = createClient(clientOptions);
client.indices.createIndex(function (err) {

@@ -153,2 +157,3 @@ assert.ifError(err);

afterEach(function (done) {
this.timeout(5000);
client.cluster.health({wait_for_status: 'yellow'}, done);

@@ -241,4 +246,3 @@ });

assert.ifError(err);
assert.deepEqual(result.metadata.templates, {});
assert(typeof result.metadata.templates[index + '_template'] === 'undefined');
done();

@@ -245,0 +249,0 @@ });

@@ -232,2 +232,17 @@ var coreLib = requireWithCoverage('core');

});
it('should properly handle _id supplied with documents', function (done) {
// add an _id to each document
for (var i = 0; i < documents.length; i++) {
documents[i]._id = i;
}
core.bulkIndex(documents, function (err, data) {
should.not.exist(err);
should.exist(data);
data.inputData.match(/_id/g).should.have.length(3);
done();
});
});
});

@@ -911,2 +926,49 @@

describe('#suggest', function () {
var suggest = {
'my-suggestion' : {
text : 'manx',
term : {
field : 'breed'
}
}
};
it('should allow request without index', function (done) {
delete defaultOptions._index;
delete defaultOptions._type;
core.suggest({}, suggest, function (err, data) {
should.not.exist(err);
should.exist(data);
data.options.path.should.equals('/_suggest');
data.options.method.should.equals('POST');
done();
});
});
it('should allow suggest without type', function (done) {
delete defaultOptions._type;
core.suggest(suggest, function (err, data) {
should.not.exist(err);
should.exist(data);
data.options.path.should.equals('/dieties/_suggest');
data.options.method.should.equals('POST');
done();
});
});
it('should allow options to be optional', function (done) {
core.suggest({}, suggest, function (err, data) {
should.not.exist(err);
should.exist(data);
data.options.path.should.equals('/dieties/kitteh/_suggest');
data.options.method.should.equals('POST');
done();
});
});
});
describe('#unregisterPercolator', function () {

@@ -913,0 +975,0 @@ it('should require index', function (done) {

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