@travetto/model-elasticsearch 3.1.6 → 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 +7 -0
- package/src/service.ts +11 -6
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
|
@@ -156,6 +156,13 @@ export class ElasticsearchQueryUtil {
|
|
|
156
156
|
items.push({ range: { [sPath]: out } });
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
|
+
case '$empty': {
|
|
160
|
+
const q = {
|
|
161
|
+
exists: { field: sPath }
|
|
162
|
+
};
|
|
163
|
+
items.push(!v ? q : { bool: { ['must_not']: q } });
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
159
166
|
case '$regex': {
|
|
160
167
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
161
168
|
const pattern = DataUtil.toRegex(v as string);
|
package/src/service.ts
CHANGED
|
@@ -61,12 +61,17 @@ export class ElasticsearchModelService implements
|
|
|
61
61
|
if (query && Object.keys(query).length === 0) {
|
|
62
62
|
query = undefined;
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
try {
|
|
65
|
+
const res = await this.client.search<T>({
|
|
66
|
+
...this.manager.getIdentity(cls),
|
|
67
|
+
...search,
|
|
68
|
+
query
|
|
69
|
+
});
|
|
70
|
+
return res;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error((err as any).meta.body.error);
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|