@travetto/model-elasticsearch 3.1.7 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/internal/query.ts +3 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-elasticsearch",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"description": "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elasticsearch",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@elastic/elasticsearch": "^8.6.0",
|
|
31
31
|
"@travetto/config": "^3.1.2",
|
|
32
32
|
"@travetto/model": "^3.1.8",
|
|
33
|
-
"@travetto/model-query": "^3.1.
|
|
33
|
+
"@travetto/model-query": "^3.1.8"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@travetto/command": "^3.1.2"
|
package/src/internal/query.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryDslQueryContainer, SearchRequest, SearchResponse, Sort, SortOptions } from '@elastic/elasticsearch/lib/api/types';
|
|
2
2
|
|
|
3
3
|
import { Class, DataUtil, ObjectUtil } from '@travetto/base';
|
|
4
4
|
import { WhereClause, SelectClause, SortClause, Query } from '@travetto/model-query';
|
|
@@ -24,18 +24,6 @@ const has$Not = (o: unknown): o is ({ $not: WhereClause<unknown> }) => !!o && '$
|
|
|
24
24
|
*/
|
|
25
25
|
export class ElasticsearchQueryUtil {
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Build the update script for a given object
|
|
29
|
-
*/
|
|
30
|
-
static generateEmptyScript(path: string): InlineScript {
|
|
31
|
-
const out: InlineScript = {
|
|
32
|
-
lang: 'painless',
|
|
33
|
-
source: 'return doc[params.key] == null || doc[params.key].size() == 0;',
|
|
34
|
-
params: { key: path },
|
|
35
|
-
};
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
27
|
/**
|
|
40
28
|
* Convert `a.b.c` to `a : { b : { c : ... }}`
|
|
41
29
|
*/
|
|
@@ -170,11 +158,9 @@ export class ElasticsearchQueryUtil {
|
|
|
170
158
|
}
|
|
171
159
|
case '$empty': {
|
|
172
160
|
const q = {
|
|
173
|
-
|
|
174
|
-
script: this.generateEmptyScript(sPath)
|
|
175
|
-
}
|
|
161
|
+
exists: { field: sPath }
|
|
176
162
|
};
|
|
177
|
-
items.push(v ? q : { bool: { ['must_not']: q } });
|
|
163
|
+
items.push(!v ? q : { bool: { ['must_not']: q } });
|
|
178
164
|
break;
|
|
179
165
|
}
|
|
180
166
|
case '$regex': {
|