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

@asymmetrik/elastic-querybuilder

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asymmetrik/elastic-querybuilder - npm Package Compare versions

Comparing version 0.9.8 to 0.9.9

51

__tests__/QueryBuilder.test.js

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

test('should build a dis_max query with sort and options', () => {
const query = new QueryBuilder()
.sort('number_detentions', { order: 'desc' })
.buildDisMax({
queries: mocks.dis_max_queries,
tie_breaker: 1.2,
boost: 2
});
expect(query).toEqual({
from: 0,
size: 15,
query: {
dis_max: {
queries: [
{ term: { age: 31 }},
{ term: { age: 32 }},
{ term: { age: 33 }}
],
tie_breaker: 1.2,
boost: 2
}
},
sort: [{
number_detentions: {
order: 'desc'
}
}]
});
});
test('should build a dis_max query with filters and options', () => {

@@ -527,2 +558,22 @@ const query = new QueryBuilder()

test('should add sorts to a functino query', () => {
const query = new QueryBuilder()
.sort('_score', {})
.buildFunctionScore();
expect(query).toEqual({
from: 0,
size: 15,
query: {
function_score: {
query: { match_all: {}},
functions: []
}
},
sort: [{
_score: {}
}]
});
});
test('should build a function_score query with a query and some functions', () => {

@@ -529,0 +580,0 @@ const query = new QueryBuilder()

2

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

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

@@ -72,2 +72,3 @@ const BaseBuilder = require('./BaseBuilder');

applyRawParameter(this._query, path, super.build());
// Add filtered aggregations if we have any

@@ -81,2 +82,3 @@ if (this.hasAggs() && options.filterAggs) {

}
// Add aggregations if we have any

@@ -116,7 +118,14 @@ else if (this.hasAggs()) {

]);
} else {
// Add the options to our query
}
// Add the options to our query
else {
applyRawParameter(this._query, 'query.dis_max', options);
}
// Add our sorting options
if (this.hasSort()) {
applyRawParameter(this._query, 'sort', this.getSorts());
}
// finally add any raw parameter that may exist

@@ -148,4 +157,6 @@ this._raw.forEach((param) => applyRawParameter(this._query, param.path, param.value));

]);
} else {
// Add the options to our query
}
// Add the options to our query
else {
applyRawParameter(this._query, 'query.multi_match', options);

@@ -158,2 +169,3 @@ }

}
// finally add any raw parameter that may exist

@@ -178,4 +190,6 @@ this._raw.forEach((param) => applyRawParameter(this._query, param.path, param.value));

applyRawParameter(this._query, queryPath, super.build());
// Apply any functions
applyRawParameter(this._query, 'query.function_score.functions', this.getFuncs());
// Add filtered aggregations if we have any

@@ -189,2 +203,3 @@ if (this.hasAggs() && options.filterAggs) {

}
// Add aggregations if we have any

@@ -194,2 +209,8 @@ else if (this.hasAggs()) {

}
// Add our sorting options
if (this.hasSort()) {
applyRawParameter(this._query, 'sort', this.getSorts());
}
// Add any raw parameters

@@ -196,0 +217,0 @@ this._raw.forEach((param) => applyRawParameter(this._query, param.path, param.value));

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