Socket
Socket
Sign inDemoInstall

@asymmetrik/elastic-querybuilder

Package Overview
Dependencies
0
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.5 to 0.9.6

47

__tests__/QueryBuilder.aggregations.test.js

@@ -161,2 +161,49 @@ const QueryBuilder = require('../src/index');

test('should build multiple nested aggregations with the same path', () => {
const query = new QueryBuilder()
.query('match_all')
/**
* Note this is not the ideal way to build these, you should just
* add the locations.state aggregation inside the first nesting. However,
* sometimes these are built dynamically and from config files, and may not
* be structured in a way that makes that easy, so building should be aware
* that there is already an agg at the same path and merge the aggregations
* instead of overriding them.
*/
.aggs('nested', { path: 'locations' }, builder => builder
.aggs('terms', 'locations.city')
)
.aggs('nested', { path: 'locations' }, builder => builder
.aggs('terms', 'locations.state')
)
.build();
expect(query).toEqual({
from: 0,
size: 15,
query: {
match_all: {}
},
aggs: {
locations: {
nested: {
path: 'locations'
},
aggs: {
'locations.city': {
terms: {
field: 'locations.city'
}
},
'locations.state': {
terms: {
field: 'locations.state'
}
}
}
}
}
});
});
test('should allow filters to be added to a normal aggregation', () => {

@@ -163,0 +210,0 @@ const query = new QueryBuilder()

2

package.json
{
"name": "@asymmetrik/elastic-querybuilder",
"version": "0.9.5",
"version": "0.9.6",
"description": "A query builder for Elasticsearch.",

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

@@ -160,3 +160,9 @@ const invariant = require('./invariant');

collection[getAggName(type, field)] = agg;
const name = getAggName(type, field);
// Handle nested aggregations with the same path, which ends up being the same name
if (nested.aggs && collection[name] && collection[name].aggs) {
Object.assign(collection[name].aggs, nested.aggs);
} else {
collection[name] = agg;
}
};

@@ -163,0 +169,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc