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

elasticsearch-helper

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch-helper - npm Package Compare versions

Comparing version

to
1.11.0

13

class/search-type.js

@@ -0,1 +1,3 @@

const _ = require('lodash');
function SearchType() {

@@ -41,2 +43,7 @@ this.sKey = false;

},
query_string(sSearch, oQB) {
this._setValues('query_string', sSearch, oQB);
return this;
},
nested(sKey, oQB) {

@@ -61,2 +68,8 @@ this._setValues('nested', sKey, oQB);

switch (this.sType) {
case 'query_string':
oObj[this.sType] = _.assignIn({
query: this.sKey,
}, this.uValue);
break;
case 'geo_distance':

@@ -63,0 +76,0 @@ oObj[this.sType] = {

59

index.js

@@ -64,41 +64,34 @@ const ES = require('elasticsearch');

const indexes = (sESClient) => {
return Promise.resolve()
.then(function(){
if(sESClient)
return getClient(sESClient)
const indexes = sESClient => Promise.resolve()
.then(() => {
if (sESClient) return getClient(sESClient);
return getClient();
})
.then(function(oClient){
if(!oClient)
return Promise.reject(new Error("Cannot find client"))
.then((oClient) => {
if (!oClient) return Promise.reject(new Error('Cannot find client'));
return oClient.cat.indices()
.then(function(resp){
return resp.split("\n");
})
.then(function(arrsIndexes){
const columns = ["health","status","index","uuid",null,null,"docs.count","docs.deleted","store.size","pri.store.size"]
const parse = [null,null,null,null,null,null,parseInt,parseInt,null,null];
const arroIndexes = [];
.then(resp => resp.split('\n'))
.then((arrsIndexes) => {
const columns = ['health', 'status', 'index', 'uuid', null, null, 'docs.count', 'docs.deleted', 'store.size', 'pri.store.size'];
const parse = [null, null, null, null, null, null, parseInt, parseInt, null, null];
const arroIndexes = [];
for(let i = 0 ; i < arrsIndexes.length; i+=1){
if(arrsIndexes[i].trim() === "")
continue;
const arrsLine = arrsIndexes[i].replace(/\s\s+/g, ' ').split(" ");
const oIndex = {}
for(let j=0; j < arrsLine.length ; j+=1){
if(columns[j]){
oIndex[columns[j]] = parse[j]? parse[j](arrsLine[j]):arrsLine[j];
for (let i = 0; i < arrsIndexes.length; i += 1) {
if (arrsIndexes[i].trim() !== '') {
const arrsLine = arrsIndexes[i].replace(/\s\s+/g, ' ').split(' ');
const oIndex = {};
for (let j = 0; j < arrsLine.length; j += 1) {
if (columns[j]) {
oIndex[columns[j]] = parse[j] ? parse[j](arrsLine[j]) : arrsLine[j];
}
}
arroIndexes.push(oIndex);
}
}
arroIndexes.push(oIndex)
}
return arroIndexes;
})
})
}
return arroIndexes;
});
});

@@ -290,3 +283,3 @@ let onErrorMethod = err => err;

},
mappings(){
mappings() {
return this._getClient().indices.getMapping({

@@ -567,2 +560,6 @@ index: this.sIndex,

},
query_string(...args) {
const oST = new SearchType();
return oST.query_string(...args);
},
nested(...args) {

@@ -569,0 +566,0 @@ const oST = new SearchType();

{
"name": "elasticsearch-helper",
"version": "1.10.0",
"version": "1.11.0",
"description": "A Nodejs module facilitating querying Elasticsearch clusters.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -378,2 +378,16 @@

* query string
More info: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
```javascript
ES.type.query_string("text to search" [,"option object"]);
// ex:
ES.type.query_string("*jabba*",{
"fields": [ "field1" ],
"analyze_wildcard": true
});
```
* nested

@@ -380,0 +394,0 @@