elasticsearch-helper
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -23,3 +23,3 @@ function AggregationBuilder() { | ||
add(...args) { | ||
return this._add(...args); | ||
return this._add(args); | ||
}, | ||
@@ -26,0 +26,0 @@ render() { |
@@ -377,3 +377,3 @@ const ES = require('elasticsearch'); | ||
aggs(...args) { | ||
this.oAB.add.apply(this.oAB, ...args); | ||
this.oAB.add(...args); | ||
return this; | ||
@@ -380,0 +380,0 @@ }, |
{ | ||
"name": "elasticsearch-helper", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "A Nodejs module facilitating querying Elasticsearch clusters.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -224,3 +224,3 @@ | ||
// initialise query | ||
var q = ES.query("Index1","Type1"); | ||
const q = ES.query("Index1","Type1"); | ||
``` | ||
@@ -249,3 +249,3 @@ | ||
.delete() | ||
.then(function(hit){ | ||
.then(function(success){ | ||
// return true | ||
@@ -433,5 +433,6 @@ }) | ||
// Types | ||
).run().then(function(hits){ | ||
).run() | ||
.then(function(hits){ | ||
// return array of hits objects | ||
var hit = hits[0]; | ||
const hit = hits[0]; | ||
console.log(hit.id()) // get Document ID | ||
@@ -451,4 +452,4 @@ console.log(hit.index()) // get Document index | ||
// Types | ||
).delete().then(function(hits){ | ||
// return array of hits objects | ||
).delete().then(function(success){ | ||
// return true | ||
}) | ||
@@ -483,11 +484,12 @@ ``` | ||
// Add more aggregations | ||
).run() | ||
) | ||
.run() | ||
.then(function(response){ | ||
// retrieve the "created_date" aggregation | ||
var arrayAggList = response.agg("created_date") | ||
var arrayValues = arrayAggList.values() // return an array of values objects. array types values will depend on the aggregation type | ||
const arrayAggList = response.agg("created_date") | ||
const arrayValues = arrayAggList.values() // return an array of values objects. array types values will depend on the aggregation type | ||
var firstValue = arrayValues[0]; | ||
var valueID = firstValue.id(); // key of the value. If it is a date_histogram type it will be a moment object | ||
var valueData = firstValue.data(); // value of the aggregation for this key. | ||
const firstValue = arrayValues[0]; | ||
const valueID = firstValue.id(); // key of the value. If it is a date_histogram type it will be a moment object | ||
const valueData = firstValue.data(); // value of the aggregation for this key. | ||
@@ -498,4 +500,4 @@ | ||
var arrayChildAggList = arrayAggList.agg("first_name"); | ||
for(var parentKeyvalue in arrayChildAggList){ | ||
const arrayChildAggList = arrayAggList.agg("first_name"); | ||
for(let parentKeyvalue in arrayChildAggList){ | ||
arrayChildAggList[parentKeyvalue].values().forEach(function(value){ | ||
@@ -619,7 +621,7 @@ console.log(parentKeyvalue, value.id(),value.data()); | ||
.must( | ||
ES.addType().term("name","John"), | ||
ES.addType().terms("lastname",["Smith","Wake"]) | ||
ES.type.term("name","John"), | ||
ES.type.terms("lastname",["Smith","Wake"]) | ||
) | ||
.must_not( | ||
ES.addType().range("age",{ | ||
ES.type.range("age",{ | ||
lte:20, | ||
@@ -662,8 +664,8 @@ gte:30 | ||
// retrieve the "created_date" aggregation | ||
var arrayAggList = response.agg("created_date") | ||
var arrayValues = arrayAggList.values() // return an array of values objects. array types values will depend on the aggregation type | ||
const arrayAggList = response.agg("created_date") | ||
const arrayValues = arrayAggList.values() // return an array of values objects. array types values will depend on the aggregation type | ||
var firstValue = arrayValues[0]; | ||
var valueID = firstValue.id(); // key of the value. If it is a date_histogram type it will be a moment object | ||
var valueData = firstValue.data(); // value of the aggregation for this key. | ||
const firstValue = arrayValues[0]; | ||
const valueID = firstValue.id(); // key of the value. If it is a date_histogram type it will be a moment object | ||
const valueData = firstValue.data(); // value of the aggregation for this key. | ||
@@ -673,4 +675,4 @@ | ||
// Note: Each parent aggregation value has its own aggregation so you will have to loop through to get the child aggregation | ||
var arrayChildAggList = arrayAggList.agg("first_name"); | ||
for(var parentKeyvalue in arrayChildAggList){ | ||
const arrayChildAggList = arrayAggList.agg("first_name"); | ||
for(let parentKeyvalue in arrayChildAggList){ | ||
arrayChildAggList[parentKeyvalue].values().forEach(function(value){ | ||
@@ -677,0 +679,0 @@ console.log(parentKeyvalue, value.id(),value.data()); |
679
46526