kuzzle 2.32.0-elasticsearch-8.1 → 2.33.0
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/README.md +0 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/kerror/index.js +1 -1
- package/lib/kuzzle/kuzzle.d.ts +5 -4
- package/lib/service/storage/7/elasticsearch.d.ts +5 -4
- package/lib/service/storage/7/elasticsearch.js +10 -9
- package/lib/service/storage/8/elasticsearch.d.ts +4 -3
- package/lib/service/storage/8/elasticsearch.js +11 -10
- package/lib/service/storage/commons/queryTranslator.d.ts +5 -0
- package/lib/service/storage/commons/queryTranslator.js +142 -172
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
<p align="center">
|
|
5
5
|
<img alt="GitHub branch checks state" src="https://img.shields.io/github/checks-status/kuzzleio/kuzzle/master">
|
|
6
6
|
<img alt="Sonarcloud" src="https://sonarcloud.io/api/project_badges/measure?project=kuzzleio_kuzzle&metric=alert_status&branch=master">
|
|
7
|
-
<a href="https://codecov.io/gh/kuzzleio/kuzzle">
|
|
8
|
-
<img src="https://codecov.io/gh/kuzzleio/kuzzle/branch/master/graph/badge.svg?token=jOrGhzslSM"/>
|
|
9
|
-
</a>
|
|
10
7
|
<a href="https://lgtm.com/projects/g/kuzzleio/kuzzle/context:javascript">
|
|
11
8
|
<img src="https://img.shields.io/lgtm/grade/javascript/g/kuzzleio/kuzzle.svg?logo=lgtm&logoWidth=18" />
|
|
12
9
|
</a>
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -31,4 +31,5 @@ __exportStar(require("./lib/core/shared/ObjectRepository"), exports);
|
|
|
31
31
|
__exportStar(require("./lib/core/shared/store"), exports);
|
|
32
32
|
__exportStar(require("./lib/core/cache/cacheDbEnum"), exports);
|
|
33
33
|
__exportStar(require("./lib/core/storage/storeScopeEnum"), exports);
|
|
34
|
+
__exportStar(require("./lib/service/storage/commons/queryTranslator"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/lib/kerror/index.js
CHANGED
|
@@ -169,7 +169,7 @@ function rawGetFrom(domains, source, domain, subdomain, error, ...placeholders)
|
|
|
169
169
|
const derivedError = rawGet(domains, domain, subdomain, error, ...placeholders);
|
|
170
170
|
// If a stacktrace is present, we need to modify the first line because it
|
|
171
171
|
// still contains the original error message
|
|
172
|
-
if (derivedError
|
|
172
|
+
if (derivedError?.stack?.length && source?.stack) {
|
|
173
173
|
const stackArray = source.stack.split("\n");
|
|
174
174
|
stackArray.shift();
|
|
175
175
|
derivedError.stack = [
|
package/lib/kuzzle/kuzzle.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import AsyncStore from "../util/asyncStore";
|
|
|
12
12
|
import { ImportConfig, InstallationConfig, StartOptions, SupportConfig } from "./../types/Kuzzle";
|
|
13
13
|
import KuzzleEventEmitter from "./event/KuzzleEventEmitter";
|
|
14
14
|
import InternalIndexHandler from "./internalIndexHandler";
|
|
15
|
+
import kuzzleStateEnum from "./kuzzleStateEnum";
|
|
15
16
|
import Logger from "./log";
|
|
16
17
|
import vault from "./vault";
|
|
17
18
|
export declare const BACKEND_IMPORT_KEY = "backend:init:import";
|
|
@@ -46,7 +47,7 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
46
47
|
/**
|
|
47
48
|
* Validation core component
|
|
48
49
|
*/
|
|
49
|
-
validation: Validation;
|
|
50
|
+
validation: typeof Validation;
|
|
50
51
|
/**
|
|
51
52
|
* Dump generator
|
|
52
53
|
*/
|
|
@@ -54,7 +55,7 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
54
55
|
/**
|
|
55
56
|
* Vault component (will be initialized after bootstrap)
|
|
56
57
|
*/
|
|
57
|
-
vault: vault;
|
|
58
|
+
vault: typeof vault;
|
|
58
59
|
/**
|
|
59
60
|
* AsyncLocalStorage wrapper
|
|
60
61
|
*/
|
|
@@ -132,8 +133,8 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
132
133
|
loadInitialState(toImport?: ImportConfig, toSupport?: SupportConfig): Promise<void>;
|
|
133
134
|
dump(suffix: any): any;
|
|
134
135
|
hash(input: any): string | Buffer;
|
|
135
|
-
get state(): kuzzleStateEnum;
|
|
136
|
-
set state(value: kuzzleStateEnum);
|
|
136
|
+
get state(): typeof kuzzleStateEnum;
|
|
137
|
+
set state(value: typeof kuzzleStateEnum);
|
|
137
138
|
/**
|
|
138
139
|
* Register handlers and do a kuzzle dump for:
|
|
139
140
|
* - system signals
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
-
import {
|
|
2
|
+
import { Client, RequestParams } from "sdk-es7";
|
|
3
3
|
import { TypeMapping } from "sdk-es7/api/types";
|
|
4
4
|
import { JSONObject, KRequestBody, KRequestParams } from "../../../types/storage/7/Elasticsearch";
|
|
5
|
-
import ESWrapper from "./esWrapper";
|
|
6
|
-
import QueryTranslator from "../commons/queryTranslator";
|
|
7
5
|
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
|
|
6
|
+
import { QueryTranslator } from "../commons/queryTranslator";
|
|
7
|
+
import ESWrapper from "./esWrapper";
|
|
8
8
|
/**
|
|
9
9
|
* @param {Kuzzle} kuzzle kuzzle instance
|
|
10
10
|
* @param {Object} config Service configuration
|
|
@@ -459,8 +459,9 @@ export declare class ES7 {
|
|
|
459
459
|
*
|
|
460
460
|
* @returns {Promise}
|
|
461
461
|
*/
|
|
462
|
-
updateCollection(index: string, collection: string, { mappings, settings, }?: {
|
|
462
|
+
updateCollection(index: string, collection: string, { mappings, reindexCollection, settings, }?: {
|
|
463
463
|
mappings?: TypeMapping;
|
|
464
|
+
reindexCollection?: boolean;
|
|
464
465
|
settings?: Record<string, any>;
|
|
465
466
|
}): Promise<any>;
|
|
466
467
|
/**
|
|
@@ -54,16 +54,16 @@ const bluebird_1 = __importDefault(require("bluebird"));
|
|
|
54
54
|
const ms_1 = __importDefault(require("ms"));
|
|
55
55
|
const semver_1 = __importDefault(require("semver"));
|
|
56
56
|
const debug_1 = __importDefault(require("../../../util/debug"));
|
|
57
|
-
const
|
|
58
|
-
const queryTranslator_1 = __importDefault(require("../commons/queryTranslator"));
|
|
59
|
-
const didYouMean_1 = __importDefault(require("../../../util/didYouMean"));
|
|
57
|
+
const storeScopeEnum_1 = require("../../../core/storage/storeScopeEnum");
|
|
60
58
|
const kerror = __importStar(require("../../../kerror"));
|
|
61
|
-
const
|
|
62
|
-
const safeObject_1 = require("../../../util/safeObject");
|
|
59
|
+
const didYouMean_1 = __importDefault(require("../../../util/didYouMean"));
|
|
63
60
|
const extractFields_1 = __importDefault(require("../../../util/extractFields"));
|
|
64
61
|
const mutex_1 = require("../../../util/mutex");
|
|
65
62
|
const name_generator_1 = require("../../../util/name-generator");
|
|
66
|
-
const
|
|
63
|
+
const requestAssertions_1 = require("../../../util/requestAssertions");
|
|
64
|
+
const safeObject_1 = require("../../../util/safeObject");
|
|
65
|
+
const queryTranslator_1 = require("../commons/queryTranslator");
|
|
66
|
+
const esWrapper_1 = __importDefault(require("./esWrapper"));
|
|
67
67
|
(0, debug_1.default)("kuzzle:services:elasticsearch");
|
|
68
68
|
const SCROLL_CACHE_PREFIX = "_docscroll_";
|
|
69
69
|
const ROOT_MAPPING_PROPERTIES = [
|
|
@@ -106,7 +106,7 @@ class ES7 {
|
|
|
106
106
|
this._client = null;
|
|
107
107
|
this._esWrapper = null;
|
|
108
108
|
this._esVersion = null;
|
|
109
|
-
this._translator = new queryTranslator_1.
|
|
109
|
+
this._translator = new queryTranslator_1.QueryTranslator();
|
|
110
110
|
// Allowed root key of a search query
|
|
111
111
|
this.searchBodyKeys = [
|
|
112
112
|
"aggregations",
|
|
@@ -1210,7 +1210,7 @@ class ES7 {
|
|
|
1210
1210
|
*
|
|
1211
1211
|
* @returns {Promise}
|
|
1212
1212
|
*/
|
|
1213
|
-
async updateCollection(index, collection, { mappings = {}, settings = {}, } = {}) {
|
|
1213
|
+
async updateCollection(index, collection, { mappings = {}, reindexCollection = false, settings = {}, } = {}) {
|
|
1214
1214
|
const esRequest = {
|
|
1215
1215
|
index: await this._getIndice(index, collection),
|
|
1216
1216
|
};
|
|
@@ -1234,7 +1234,8 @@ class ES7 {
|
|
|
1234
1234
|
includeKuzzleMeta: true,
|
|
1235
1235
|
});
|
|
1236
1236
|
await this.updateMapping(index, collection, mappings);
|
|
1237
|
-
if (
|
|
1237
|
+
if (reindexCollection ||
|
|
1238
|
+
this._dynamicChanges(previousMappings, mappings)) {
|
|
1238
1239
|
await this.updateSearchIndex(index, collection);
|
|
1239
1240
|
}
|
|
1240
1241
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import { Client, estypes } from "sdk-es8";
|
|
3
3
|
import { InfoResult, JSONObject, KRequestBody, KRequestParams, KStats, KUpdateResponse } from "../../../types/storage/8/Elasticsearch";
|
|
4
|
-
import ESWrapper from "./esWrapper";
|
|
5
|
-
import QueryTranslator from "../commons/queryTranslator";
|
|
6
4
|
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
|
|
5
|
+
import { QueryTranslator } from "../commons/queryTranslator";
|
|
6
|
+
import ESWrapper from "./esWrapper";
|
|
7
7
|
/**
|
|
8
8
|
* @param {Kuzzle} kuzzle kuzzle instance
|
|
9
9
|
* @param {Object} config Service configuration
|
|
@@ -454,8 +454,9 @@ export declare class ES8 {
|
|
|
454
454
|
*
|
|
455
455
|
* @returns {Promise}
|
|
456
456
|
*/
|
|
457
|
-
updateCollection(index: string, collection: string, { mappings, settings, }?: {
|
|
457
|
+
updateCollection(index: string, collection: string, { mappings, reindexCollection, settings, }?: {
|
|
458
458
|
mappings?: estypes.MappingTypeMapping;
|
|
459
|
+
reindexCollection?: boolean;
|
|
459
460
|
settings?: Record<string, any>;
|
|
460
461
|
}): Promise<any>;
|
|
461
462
|
/**
|
|
@@ -50,20 +50,20 @@ exports.ES8 = void 0;
|
|
|
50
50
|
const lodash_1 = __importDefault(require("lodash"));
|
|
51
51
|
const sdk_es8_1 = require("sdk-es8");
|
|
52
52
|
const assert_1 = __importDefault(require("assert"));
|
|
53
|
-
const ms_1 = __importDefault(require("ms"));
|
|
54
53
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
54
|
+
const ms_1 = __importDefault(require("ms"));
|
|
55
55
|
const semver_1 = __importDefault(require("semver"));
|
|
56
|
+
const storeScopeEnum_1 = require("../../../core/storage/storeScopeEnum");
|
|
57
|
+
const kerror = __importStar(require("../../../kerror"));
|
|
56
58
|
const debug_1 = __importDefault(require("../../../util/debug"));
|
|
57
|
-
const esWrapper_1 = __importDefault(require("./esWrapper"));
|
|
58
|
-
const queryTranslator_1 = __importDefault(require("../commons/queryTranslator"));
|
|
59
59
|
const didYouMean_1 = __importDefault(require("../../../util/didYouMean"));
|
|
60
|
-
const kerror = __importStar(require("../../../kerror"));
|
|
61
|
-
const requestAssertions_1 = require("../../../util/requestAssertions");
|
|
62
|
-
const safeObject_1 = require("../../../util/safeObject");
|
|
63
|
-
const storeScopeEnum_1 = require("../../../core/storage/storeScopeEnum");
|
|
64
60
|
const extractFields_1 = __importDefault(require("../../../util/extractFields"));
|
|
65
61
|
const mutex_1 = require("../../../util/mutex");
|
|
66
62
|
const name_generator_1 = require("../../../util/name-generator");
|
|
63
|
+
const requestAssertions_1 = require("../../../util/requestAssertions");
|
|
64
|
+
const safeObject_1 = require("../../../util/safeObject");
|
|
65
|
+
const queryTranslator_1 = require("../commons/queryTranslator");
|
|
66
|
+
const esWrapper_1 = __importDefault(require("./esWrapper"));
|
|
67
67
|
(0, debug_1.default)("kuzzle:services:elasticsearch");
|
|
68
68
|
const SCROLL_CACHE_PREFIX = "_docscroll_";
|
|
69
69
|
const ROOT_MAPPING_PROPERTIES = [
|
|
@@ -106,7 +106,7 @@ class ES8 {
|
|
|
106
106
|
this._client = null;
|
|
107
107
|
this._esWrapper = null;
|
|
108
108
|
this._esVersion = null;
|
|
109
|
-
this._translator = new queryTranslator_1.
|
|
109
|
+
this._translator = new queryTranslator_1.QueryTranslator();
|
|
110
110
|
// Allowed root key of a search query
|
|
111
111
|
this.searchBodyKeys = [
|
|
112
112
|
"aggregations",
|
|
@@ -1211,7 +1211,7 @@ class ES8 {
|
|
|
1211
1211
|
*
|
|
1212
1212
|
* @returns {Promise}
|
|
1213
1213
|
*/
|
|
1214
|
-
async updateCollection(index, collection, { mappings = {}, settings = {}, } = {}) {
|
|
1214
|
+
async updateCollection(index, collection, { mappings = {}, reindexCollection = false, settings = {}, } = {}) {
|
|
1215
1215
|
const esRequest = {
|
|
1216
1216
|
index: await this._getIndice(index, collection),
|
|
1217
1217
|
};
|
|
@@ -1235,7 +1235,8 @@ class ES8 {
|
|
|
1235
1235
|
includeKuzzleMeta: true,
|
|
1236
1236
|
});
|
|
1237
1237
|
await this.updateMapping(index, collection, mappings);
|
|
1238
|
-
if (
|
|
1238
|
+
if (reindexCollection ||
|
|
1239
|
+
this._dynamicChanges(previousMappings, mappings)) {
|
|
1239
1240
|
await this.updateSearchIndex(index, collection);
|
|
1240
1241
|
}
|
|
1241
1242
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryTranslator = void 0;
|
|
1
4
|
/*
|
|
2
5
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
6
|
* to power modern apps
|
|
@@ -18,23 +21,14 @@
|
|
|
18
21
|
* See the License for the specific language governing permissions and
|
|
19
22
|
* limitations under the License.
|
|
20
23
|
*/
|
|
21
|
-
|
|
22
|
-
"use strict";
|
|
23
|
-
|
|
24
|
-
const kerror = require("../../../kerror");
|
|
25
|
-
|
|
24
|
+
const kerror_1 = require("../../../kerror");
|
|
26
25
|
class KeywordError extends Error {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.keyword = { name, type };
|
|
33
|
-
}
|
|
26
|
+
constructor(type, name) {
|
|
27
|
+
super(`The ${type} "${name}" of Koncorde DSL is not supported for search queries.`);
|
|
28
|
+
this.keyword = { name, type };
|
|
29
|
+
}
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
const KONCORDE_OPERATORS = ["and", "or", "not", "bool"];
|
|
37
|
-
|
|
38
32
|
/**
|
|
39
33
|
* Parse the Koncorde path to extract the path and the value
|
|
40
34
|
* path have the form "path.to.field[json_value]"
|
|
@@ -43,177 +37,153 @@ const KONCORDE_OPERATORS = ["and", "or", "not", "bool"];
|
|
|
43
37
|
* @returns
|
|
44
38
|
*/
|
|
45
39
|
function parseKoncordePath(path) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const firstBracket = path.indexOf("[");
|
|
41
|
+
if (firstBracket < 0) {
|
|
42
|
+
return {
|
|
43
|
+
path,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const lastBracket = path.lastIndexOf("]");
|
|
47
|
+
if (lastBracket < 0) {
|
|
48
|
+
throw (0, kerror_1.get)("services", "koncorde", "elastic_translation_error", `Invalid exists path "${path}": missing closing bracket`);
|
|
49
|
+
}
|
|
49
50
|
return {
|
|
50
|
-
|
|
51
|
+
path: path.slice(0, firstBracket),
|
|
52
|
+
value: JSON.parse(path.slice(firstBracket + 1, lastBracket)),
|
|
51
53
|
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const lastBracket = path.lastIndexOf("]");
|
|
55
|
-
|
|
56
|
-
if (lastBracket < 0) {
|
|
57
|
-
throw kerror.get(
|
|
58
|
-
"services",
|
|
59
|
-
"koncorde",
|
|
60
|
-
"elastic_translation_error",
|
|
61
|
-
`Invalid exists path "${path}": missing closing bracket`,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
path: path.slice(0, firstBracket),
|
|
67
|
-
value: JSON.parse(path.slice(firstBracket + 1, lastBracket)),
|
|
68
|
-
};
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
const KONCORDE_CLAUSES_TO_ES = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
56
|
+
equals: (content) => ({
|
|
57
|
+
term: {
|
|
58
|
+
...content,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
exists: (field) => {
|
|
62
|
+
// Support old syntax { exists: { field: "path" } } and { exists: "path" }
|
|
63
|
+
const parsedInfo = parseKoncordePath(field.field || field);
|
|
64
|
+
// If we have a value, we need to use a range query to be sure that the value is the same
|
|
65
|
+
if (parsedInfo.value) {
|
|
66
|
+
return {
|
|
67
|
+
bool: {
|
|
68
|
+
filter: [
|
|
69
|
+
{
|
|
70
|
+
exists: {
|
|
71
|
+
field: parsedInfo.path,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
range: {
|
|
76
|
+
[parsedInfo.path]: {
|
|
77
|
+
gte: parsedInfo.value,
|
|
78
|
+
lte: parsedInfo.value,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
96
83
|
},
|
|
97
|
-
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
exists: {
|
|
88
|
+
field: parsedInfo.path,
|
|
98
89
|
},
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
exists: {
|
|
106
|
-
field: parsedInfo.path,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
geoBoundingBox: (content) => ({
|
|
111
|
-
geo_bounding_box: {
|
|
112
|
-
...content,
|
|
113
|
-
},
|
|
114
|
-
}),
|
|
115
|
-
geoDistance: (content) => ({
|
|
116
|
-
geo_distance: {
|
|
117
|
-
...content,
|
|
118
|
-
},
|
|
119
|
-
}),
|
|
120
|
-
geoDistanceRange: (content) => ({
|
|
121
|
-
geo_distance_range: {
|
|
122
|
-
...content,
|
|
123
|
-
},
|
|
124
|
-
}),
|
|
125
|
-
geoPolygon: (content) => ({
|
|
126
|
-
geo_polygon: {
|
|
127
|
-
...content,
|
|
128
|
-
},
|
|
129
|
-
}),
|
|
130
|
-
ids: (content) => ({
|
|
131
|
-
ids: {
|
|
132
|
-
...content,
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
in: (content) => ({
|
|
136
|
-
terms: {
|
|
137
|
-
...content,
|
|
90
|
+
};
|
|
138
91
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
|
|
92
|
+
geoBoundingBox: (content) => ({
|
|
93
|
+
geo_bounding_box: {
|
|
94
|
+
...content,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
geoDistance: (content) => ({
|
|
98
|
+
geo_distance: {
|
|
99
|
+
...content,
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
geoDistanceRange: (content) => ({
|
|
103
|
+
geo_distance_range: {
|
|
104
|
+
...content,
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
geoPolygon: (content) => ({
|
|
108
|
+
geo_polygon: {
|
|
109
|
+
...content,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
ids: (content) => ({
|
|
113
|
+
ids: {
|
|
114
|
+
...content,
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
in: (content) => ({
|
|
118
|
+
terms: {
|
|
119
|
+
...content,
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
missing: (field) => ({
|
|
123
|
+
bool: {
|
|
124
|
+
must_not: [{ exists: { field } }],
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
range: (content) => ({
|
|
128
|
+
range: {
|
|
129
|
+
...content,
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
150
132
|
};
|
|
151
|
-
|
|
152
133
|
const KONCORDE_OPERATORS_TO_ES = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
or: (content) => ({
|
|
169
|
-
bool: {
|
|
170
|
-
should: [...content],
|
|
134
|
+
and: (content) => ({
|
|
135
|
+
bool: {
|
|
136
|
+
filter: [...content],
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
bool: undefined,
|
|
140
|
+
not: (content) => {
|
|
141
|
+
const [name, value] = Object.entries(content[0])[0];
|
|
142
|
+
return {
|
|
143
|
+
bool: {
|
|
144
|
+
must_not: [{ [name]: value }],
|
|
145
|
+
},
|
|
146
|
+
};
|
|
171
147
|
},
|
|
172
|
-
|
|
148
|
+
or: (content) => ({
|
|
149
|
+
bool: {
|
|
150
|
+
should: [...content],
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
173
153
|
};
|
|
174
|
-
|
|
175
154
|
class QueryTranslator {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return this._translateClause(name, value);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
_translateOperator(operator, operands) {
|
|
187
|
-
const converter = KONCORDE_OPERATORS_TO_ES[operator];
|
|
188
|
-
|
|
189
|
-
if (converter === undefined) {
|
|
190
|
-
throw new KeywordError("operator", operator);
|
|
155
|
+
translate(filters) {
|
|
156
|
+
const [name, value] = Object.entries(filters)[0];
|
|
157
|
+
if (KONCORDE_OPERATORS.includes(name)) {
|
|
158
|
+
return this._translateOperator(name, value);
|
|
159
|
+
}
|
|
160
|
+
return this._translateClause(name, value);
|
|
191
161
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
162
|
+
_translateOperator(operator, operands) {
|
|
163
|
+
const converter = KONCORDE_OPERATORS_TO_ES[operator];
|
|
164
|
+
if (converter === undefined) {
|
|
165
|
+
throw new KeywordError("operator", operator);
|
|
166
|
+
}
|
|
167
|
+
const esOperands = [];
|
|
168
|
+
if (operator === "not") {
|
|
169
|
+
esOperands.push(this.translate(operands));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
for (const operand of operands) {
|
|
173
|
+
esOperands.push(this.translate(operand));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return converter(esOperands);
|
|
201
177
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return {
|
|
211
|
-
[clause]: content,
|
|
212
|
-
};
|
|
178
|
+
_translateClause(clause, content) {
|
|
179
|
+
const converter = KONCORDE_CLAUSES_TO_ES[clause];
|
|
180
|
+
if (converter === undefined) {
|
|
181
|
+
return {
|
|
182
|
+
[clause]: content,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return converter(content);
|
|
213
186
|
}
|
|
214
|
-
|
|
215
|
-
return converter(content);
|
|
216
|
-
}
|
|
217
187
|
}
|
|
218
|
-
|
|
219
|
-
|
|
188
|
+
exports.QueryTranslator = QueryTranslator;
|
|
189
|
+
//# sourceMappingURL=queryTranslator.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.33.0",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"clean": "touch index.ts && npm run build | grep TSFILE | cut -d' ' -f 2 | xargs rm",
|
|
10
|
-
"codecov": "codecov",
|
|
11
10
|
"cucumber": "cucumber.js --fail-fast",
|
|
12
11
|
"dev": "ergol docker/scripts/start-kuzzle-dev.ts -c ./config/ergol.config.json",
|
|
13
12
|
"doc-error-codes": "node -r ts-node/register doc/build-error-codes",
|
|
@@ -45,9 +44,9 @@
|
|
|
45
44
|
"json2yaml": "1.1.0",
|
|
46
45
|
"jsonwebtoken": "9.0.2",
|
|
47
46
|
"koncorde": "4.3.0",
|
|
48
|
-
"kuzzle-plugin-auth-passport-local": "6.4.
|
|
47
|
+
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
49
48
|
"kuzzle-plugin-logger": "3.0.3",
|
|
50
|
-
"kuzzle-sdk": "^7.
|
|
49
|
+
"kuzzle-sdk": "^7.13.0",
|
|
51
50
|
"kuzzle-vault": "2.0.4",
|
|
52
51
|
"lodash": "4.17.21",
|
|
53
52
|
"long": "5.2.3",
|
|
@@ -92,7 +91,6 @@
|
|
|
92
91
|
"@types/lodash": "4.14.202",
|
|
93
92
|
"async": "3.2.5",
|
|
94
93
|
"chokidar": "3.5.3",
|
|
95
|
-
"codecov": "3.8.3",
|
|
96
94
|
"cucumber": "6.0.5",
|
|
97
95
|
"cz-conventional-changelog": "^3.3.0",
|
|
98
96
|
"ergol": "1.0.2",
|