New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

etk

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

etk - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

21

index.js

@@ -193,3 +193,22 @@

var query = this._query(query_body, opt);
this.client.search(query, cb );
this.client.search(query, this._listAllCb(cb, this));
},
_listAllCb: function (cb, self) {
var self = self;
return function(err, resp) {
if (err) {
cb(err, resp);
} else {
if (self.raw_response) {
cb(err, resp);
} else {
// Return only the data as array
var resp_array = [];
for (var item in resp['hits']['hits']) {
resp_array.push(resp['hits']['hits'][item]['_source']);
}
cb(err, resp_array);
}
}
}
}

@@ -196,0 +215,0 @@ };

2

package.json
{
"name": "etk",
"version": "0.0.7",
"version": "0.0.8",
"description": "Elastic search tool kit.",

@@ -5,0 +5,0 @@ "license": "MIT",

## ElasticSearch Tool Kit
Makes life easy with ElasticSearch.
[![Linux Build][travis-image]][travis-url]

@@ -7,13 +9,40 @@ [![Dependency Status][david-dm-dev-image]][david-dm-dev-url]

elastic = require('elasticsearch');
Etk = require('etk');
Makes life easy with ElasticSearch.
var client = elastic.Client({hosts: ['localhost:9200']});
Work in progress. Keep your seatbelts fastened.
client_1 = Etk(client, {index: "my_index", type: "my_type"});
client_1.tk.search("foo", "bar", function (err, resp) {
...
});
## API Documentation
client_2 = Etk(client, {index: "another_index", type: "another_type"});
client_2.tk.search("baz", "bar", function (err, resp) {
...
});
## Installation
$ npm install etk
## Features
* Extents the official [elasticsearch](https://github.com/elastic/elasticsearch-js) project with easy to use, well documented function calls.
* Parses elasticsearch error and response messages in useful ways. Yet you have the option to receive them as they are with configuration options.
* Etk library is inserted into elasticsearch with "tk" namespace.
* Uses same elasticsearch instance in multiple Etk clients.
* All API calls are tested against the latest elasticsearch release.
* elasticsearch can be used alongside without any change.
## API Documentation with Examples
[Site-Link](http://saltukalakus.github.io/etk)
## People
Original author of Etk is [R. Saltuk Alakus](https://github.com/saltukalakus)
Looking for maintainers. Please drop me an email at saltukalakus@gmail.com
## License
[MIT](LICENSE)
[MIT](LICENSE)

@@ -20,0 +49,0 @@ [travis-image]: https://travis-ci.org/saltukalakus/etk.svg?branch=master

var test = require('tape');
var elastic = require('elasticsearch');
var etk = require('../index');
var Etk = require('../index');

@@ -11,3 +11,3 @@ var client = elastic.Client({

var client_1 = new etk(client, {index: "myindex", type: "mytype", raw_error: true});
var client_1 = new Etk(client, {index: "myindex", type: "mytype"});

@@ -48,2 +48,15 @@ /*

test("Delete data set", function(t) {
function cb (err, resp) {
if (err)
t.fail("ERR: " + JSON.stringify(err));
}
client_1.tk.deleteAll(function(err, resp){
if (err) {
t.fail("Data set could not be cleared. ERR: " + JSON.stringify(err));
}
});
t.end();
});
test("Populate the data set", function(t) {

@@ -72,5 +85,25 @@ function cb (err, resp) {

console.log(JSON.stringify(resp));
//for (var item in resp['hits']['hits']) {
for (var item in resp) {
//t.equal(JSON.stringify(test_array[item]), JSON.stringify(resp['hits']['hits'][item]['_source']));
t.equal(JSON.stringify(test_array[item]), JSON.stringify(resp[item]));
}
}
for (var item in resp['hits']['hits']) {
setTimeout(function() {
// Give elastic search some time to index
client_1.tk.listAll(cb, {"sort": "id"});
}, 3000);
});
/*
test("Verify in raw response mode, if the data set is successfully stored", function(t) {
t.plan(3);
function cb (err, resp) {
if (err) {
t.fail("ERR: " + JSON.stringify(err));
}
for (var item in resp['hits']['hits']) {
t.equal(JSON.stringify(test_array[item]), JSON.stringify(resp['hits']['hits'][item]['_source']));

@@ -82,9 +115,16 @@ }

// Give elastic search some time to index
client_1.tk.listAll(cb, {"sort": "id"});
client_1.tk.listAll(cb, {"sort": "id", "raw_response": true});
}, 3000);
});
*/
test("Search the data set with success", function(t){
function cb(err, resp) {
if (err) {
t.fail("ERR: " + JSON.stringify(err));
}
}
setTimeout(function() {
console.log('Blah blah blah blah extra-blah');
//client_1.tk.search(cb, )
}, 3000);

@@ -91,0 +131,0 @@ t.end();

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