Socket
Socket
Sign inDemoInstall

elastic-dsl-typescript

Package Overview
Dependencies
0
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.4 to 1.1.5

20

Builders/Bool/index.js

@@ -15,15 +15,15 @@ "use strict";

Should(filter, data) {
this.add("should", filter, data);
this.add('should', filter, data);
return this;
}
Filter(filter, data) {
this.add("filter", filter, data);
this.add('filter', filter, data);
return this;
}
Must(filter, data) {
this.add("must", filter, data);
this.add('must', filter, data);
return this;
}
Must_Not(filter, data) {
this.add("must_not", filter, data);
this.add('must_not', filter, data);
return this;

@@ -61,12 +61,12 @@ }

switch (filter) {
case "exists": {
case 'exists': {
(_a = this._query[type]) === null || _a === void 0 ? void 0 : _a.push({
[filter]: { field: data.params.fieldName }
[filter]: { field: data.params.fieldName },
});
break;
}
case "term":
case "terms": {
case 'term':
case 'terms': {
(_b = this._query[type]) === null || _b === void 0 ? void 0 : _b.push({
[filter]: Object.assign({ [data["field"]]: data.params["value"] }, data.opts)
[filter]: Object.assign({ [data['field']]: data.params['value'] }, data.opts),
});

@@ -81,3 +81,3 @@ break;

(_c = this._query[type]) === null || _c === void 0 ? void 0 : _c.push({
[filter]: { [data["field"]]: payload }
[filter]: { [data['field']]: payload },
});

@@ -84,0 +84,0 @@ }

@@ -16,3 +16,3 @@ import { AbstractBulder } from '../..';

*/
add<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]): Omit<this, "add">;
add<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]): Omit<this, 'add'>;
/**

@@ -19,0 +19,0 @@ * Generate Json

@@ -14,3 +14,3 @@ "use strict";

isNotEmty() {
return Object.keys(this._query).filter((field) => field.length).length > 0;
return Object.keys(this._query).filter(field => field.length).length > 0;
}

@@ -27,4 +27,4 @@ /**

[filter]: {
[data.field]: Object.assign(Object.assign({}, data.params), data.opts)
}
[data.field]: Object.assign(Object.assign({}, data.params), data.opts),
},
};

@@ -34,3 +34,3 @@ }

this._query = {
[filter]: Object.assign(Object.assign({}, data.params), data.opts)
[filter]: Object.assign(Object.assign({}, data.params), data.opts),
};

@@ -37,0 +37,0 @@ }

@@ -9,3 +9,4 @@ import { Schema } from '../../Abstract/Schema';

* @property match_phrase like the match query but used for matching exact phrases or word proximity matches.
* @property query_string returns documents based on a provided query string, using a parser with a strict syntax.
* @property query_string Supports the compact Lucene query string syntax, allowing you to specify AND|OR|NOT conditions and multi-field search within a single query string. For expert users only.
* @property combined_fields Matches Over multiple fields as if they had been indexed into one combined field..
*/

@@ -35,4 +36,11 @@ export interface TextSchema extends Schema {

};
opts: AllowLeadingWildcard | AutoGenerateSynonymsPhraseQuery | Boost | Operator | Analyzer | DefaultField | FuzzyTranspositions | FuzzyPrefixLength | FuzzyTranspositions | FuzzyPrefixLength | Lenient | AnalyzeWildcard;
opts?: AllowLeadingWildcard & AutoGenerateSynonymsPhraseQuery & Boost & Operator & Analyzer & DefaultField & FuzzyTranspositions & FuzzyPrefixLength & FuzzyTranspositions & FuzzyPrefixLength & Lenient & AnalyzeWildcard;
};
combined_fields: {
params: {
query: string;
fields: string[];
};
opts?: Operator & AutoGenerateSynonymsPhraseQuery & MinimumShouldMatch & ZeroTermsQuery;
};
}
{
"name": "elastic-dsl-typescript",
"version": "1.1.4",
"version": "1.1.5",
"description": "Node.js ElasticSearch search query builder",

@@ -5,0 +5,0 @@ "main": "./",

import { TEXT } from '../../Builders/Text';
describe('TEXT tests', () => {
test('Create TEXT query ', async () => {
test('Create match query ', async () => {
const t = new TEXT()

@@ -10,13 +10,13 @@

params: {
query: "search text"
query: 'search text',
},
opts: {
max_expansions: 1,
analyzer: "russian",
analyzer: 'russian',
auto_generate_synonyms_phrase_query: true,
fuzziness: "6",
operator: "AND",
fuzziness: '6',
operator: 'AND',
prefix_length: 15,
fuzzy_transpositions: true
}
fuzzy_transpositions: true,
},
})

@@ -27,17 +27,47 @@

expect(t).toHaveProperty(
"match",
'match',
expect.objectContaining({
testField: {
analyzer: "russian",
analyzer: 'russian',
auto_generate_synonyms_phrase_query: true,
fuzziness: "6",
fuzziness: '6',
fuzzy_transpositions: true,
max_expansions: 1,
operator: "AND",
operator: 'AND',
prefix_length: 15,
query: "search text"
}
query: 'search text',
},
}),
);
});
test('Create query_string ', async () => {
const t = new TEXT()
.add('query_string', {
params: {
query: 'search text',
},
opts: {
default_field: 'my_text',
analyzer: 'russian',
auto_generate_synonyms_phrase_query: true,
operator: 'AND',
fuzzy_transpositions: true,
},
})
.build();
expect(t).toHaveProperty(
'query_string',
expect.objectContaining({
analyzer: 'russian',
auto_generate_synonyms_phrase_query: true,
default_field: 'my_text',
fuzzy_transpositions: true,
operator: 'AND',
query: 'search text',
}),
);
});
});

@@ -17,3 +17,3 @@ import { AbstractBulder } from '../../Abstract/AbstractBuilder';

public Should<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]) {
this.add("should", filter, data);
this.add('should', filter, data);
return this;

@@ -23,3 +23,3 @@ }

public Filter<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]) {
this.add("filter", filter, data);
this.add('filter', filter, data);
return this;

@@ -29,3 +29,3 @@ }

public Must<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]) {
this.add("must", filter, data);
this.add('must', filter, data);
return this;

@@ -35,3 +35,3 @@ }

public Must_Not<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]) {
this.add("must_not", filter, data);
this.add('must_not', filter, data);
return this;

@@ -71,12 +71,12 @@ }

switch (filter) {
case "exists": {
case 'exists': {
this._query[type]?.push({
[filter]: { field: (data.params as BASE_SCHEMA["exists"]["params"]).fieldName }
[filter]: { field: (data.params as BASE_SCHEMA['exists']['params']).fieldName },
});
break;
}
case "term":
case "terms": {
case 'term':
case 'terms': {
this._query[type]?.push({
[filter]: { [data["field"]!]: (data.params as object)["value"], ...(data.opts as object) }
[filter]: { [data['field']!]: (data.params as object)['value'], ...(data.opts as object) },
});

@@ -93,3 +93,3 @@ break;

this._query[type]?.push({
[filter]: { [data["field"]!]: payload }
[filter]: { [data['field']!]: payload },
});

@@ -96,0 +96,0 @@ }

@@ -141,2 +141,3 @@ import { Schema } from '../../Abstract/Schema';

};
}

@@ -12,3 +12,3 @@ import { AbstractBulder } from '../..';

public isNotEmty(): boolean {
return Object.keys(this._query).filter((field) => field.length).length > 0;
return Object.keys(this._query).filter(field => field.length).length > 0;
}

@@ -22,12 +22,12 @@

*/
public add<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]): Omit<this, "add"> {
public add<K extends keyof BASE_SCHEMA>(filter: K, data: BASE_SCHEMA[K]): Omit<this, 'add'> {
if (data.field) {
this._query = {
[filter]: {
[data.field]: { ...(data.params as object), ...(data.opts as object) }
}
[data.field]: { ...(data.params as object), ...(data.opts as object) },
},
};
} else {
this._query = {
[filter]: { ...(data.params as object), ...(data.opts as object) }
[filter]: { ...(data.params as object), ...(data.opts as object) },
};

@@ -34,0 +34,0 @@ }

@@ -17,3 +17,3 @@ import { Schema } from '../../Abstract/Schema';

PrefixLength,
ZeroTermsQuery
ZeroTermsQuery,
} from '../../Types/QueryOptions';

@@ -27,3 +27,4 @@

* @property match_phrase like the match query but used for matching exact phrases or word proximity matches.
* @property query_string returns documents based on a provided query string, using a parser with a strict syntax.
* @property query_string Supports the compact Lucene query string syntax, allowing you to specify AND|OR|NOT conditions and multi-field search within a single query string. For expert users only.
* @property combined_fields Matches Over multiple fields as if they had been indexed into one combined field..
*/

@@ -38,3 +39,2 @@ export interface TextSchema extends Schema {

field: string;
params: {

@@ -67,17 +67,22 @@ query: string | Date | number;

};
opts:
| AllowLeadingWildcard
| AutoGenerateSynonymsPhraseQuery
| Boost
| Operator
| Analyzer
| DefaultField
| FuzzyTranspositions
| FuzzyPrefixLength
| FuzzyTranspositions
| FuzzyPrefixLength
| Lenient
| AnalyzeWildcard;
opts?: AllowLeadingWildcard &
AutoGenerateSynonymsPhraseQuery &
Boost &
Operator &
Analyzer &
DefaultField &
FuzzyTranspositions &
FuzzyPrefixLength &
FuzzyTranspositions &
FuzzyPrefixLength &
Lenient &
AnalyzeWildcard;
};
combined_fields: {
params: {
query: string;
fields: string[];
};
opts?: Operator & AutoGenerateSynonymsPhraseQuery & MinimumShouldMatch & ZeroTermsQuery;
};
}

@@ -5,3 +5,3 @@ export interface Boost {

*/
boost: number;
boost?: number;
}

@@ -8,0 +8,0 @@

@@ -5,3 +5,3 @@ export interface Boost {

*/
boost: number;
boost?: number;
}

@@ -8,0 +8,0 @@ export interface Operator {

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