@toxplanet/pegasus-sdk 1.1.0 → 1.1.1
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/lib/chemicals.js +40 -40
- package/lib/documents.js +32 -32
- package/lib/search.js +19 -19
- package/package.json +1 -1
package/lib/chemicals.js
CHANGED
|
@@ -239,52 +239,52 @@ class ChemicalsService {
|
|
|
239
239
|
|
|
240
240
|
indexPatterns.forEach(pattern => {
|
|
241
241
|
elasticsearchService.registerIndexRoute(pattern, {
|
|
242
|
-
|
|
242
|
+
index: async (params) => {
|
|
243
243
|
const chemical = params.body;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
bulk: async (params) => {
|
|
248
|
-
const operations = params.body || params.operations;
|
|
249
|
-
const documents = [];
|
|
244
|
+
return await this.createChemical(chemical);
|
|
245
|
+
},
|
|
250
246
|
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
const
|
|
247
|
+
bulk: async (params) => {
|
|
248
|
+
const operations = params.body || params.operations;
|
|
249
|
+
const documents = [];
|
|
254
250
|
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
for (let i = 0; i < operations.length; i += 2) {
|
|
252
|
+
const action = operations[i];
|
|
253
|
+
const document = operations[i + 1];
|
|
254
|
+
|
|
255
|
+
if (action.index || action.create) {
|
|
256
|
+
documents.push(document);
|
|
257
|
+
}
|
|
257
258
|
}
|
|
258
|
-
|
|
259
|
+
|
|
260
|
+
return await this.bulkIndexFielded(documents);
|
|
261
|
+
},
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
get: async (params) => {
|
|
264
|
-
return await this.getChemicalById(params.id);
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
update: async (params) => {
|
|
268
|
-
return await this.updateChemical(params.id, params.body);
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
delete: async (params) => {
|
|
272
|
-
return await this.deleteChemical(params.id);
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
search: async (params) => {
|
|
276
|
-
const query = params.body?.query;
|
|
277
|
-
const searchTerm = query?.match?.chemical_name ||
|
|
278
|
-
query?.term?.chemical_name ||
|
|
279
|
-
query?.query_string?.query || '';
|
|
280
|
-
const limit = params.body?.size || 10;
|
|
263
|
+
get: async (params) => {
|
|
264
|
+
return await this.getChemicalById(params.id);
|
|
265
|
+
},
|
|
281
266
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
267
|
+
update: async (params) => {
|
|
268
|
+
return await this.updateChemical(params.id, params.body);
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
delete: async (params) => {
|
|
272
|
+
return await this.deleteChemical(params.id);
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
search: async (params) => {
|
|
276
|
+
const query = params.body?.query;
|
|
277
|
+
const searchTerm = query?.match?.chemical_name ||
|
|
278
|
+
query?.term?.chemical_name ||
|
|
279
|
+
query?.query_string?.query || '';
|
|
280
|
+
const limit = params.body?.size || 10;
|
|
281
|
+
|
|
282
|
+
return await this.searchByName(searchTerm, limit);
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
count: async (params) => {
|
|
286
|
+
return await this.countAll();
|
|
287
|
+
}
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
290
|
}
|
package/lib/documents.js
CHANGED
|
@@ -50,42 +50,42 @@ class DocumentsService {
|
|
|
50
50
|
|
|
51
51
|
indexPatterns.forEach(pattern => {
|
|
52
52
|
elasticsearchService.registerIndexRoute(pattern, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
bulk: async (params) => {
|
|
59
|
-
const operations = params.body || params.operations;
|
|
60
|
-
const documents = [];
|
|
53
|
+
index: async (params) => {
|
|
54
|
+
const document = params.body;
|
|
55
|
+
return await this.createDocument(document.document_path, document.cas_numbers || []);
|
|
56
|
+
},
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
58
|
+
bulk: async (params) => {
|
|
59
|
+
const operations = params.body || params.operations;
|
|
60
|
+
const documents = [];
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
for (let i = 0; i < operations.length; i += 2) {
|
|
63
|
+
const action = operations[i];
|
|
64
|
+
const document = operations[i + 1];
|
|
65
|
+
|
|
66
|
+
if (action.index || action.create) {
|
|
67
|
+
documents.push(document);
|
|
68
|
+
}
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
|
|
71
|
+
return await this.bulkCreateDocuments(documents);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
get: async (params) => {
|
|
75
|
+
return await this.getDocumentById(params.id);
|
|
76
|
+
},
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
delete: async (params) => {
|
|
83
|
-
return await this.deleteDocument(params.id);
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
count: async (params) => {
|
|
87
|
-
return await this.countDocuments();
|
|
88
|
-
}
|
|
78
|
+
update: async (params) => {
|
|
79
|
+
return await this.updateDocument(params.id, params.body);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
delete: async (params) => {
|
|
83
|
+
return await this.deleteDocument(params.id);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
count: async (params) => {
|
|
87
|
+
return await this.countDocuments();
|
|
88
|
+
}
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
}
|
package/lib/search.js
CHANGED
|
@@ -308,26 +308,26 @@ class SearchService {
|
|
|
308
308
|
|
|
309
309
|
indexPatterns.forEach(pattern => {
|
|
310
310
|
elasticsearchService.registerIndexRoute(pattern, {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
311
|
+
search: async (params) => {
|
|
312
|
+
const query = params.body?.query;
|
|
313
|
+
const searchTerm = query?.match?.chemical_name ||
|
|
314
|
+
query?.term?.chemical_name ||
|
|
315
|
+
query?.query_string?.query ||
|
|
316
|
+
query?.match_all ? '*' : '';
|
|
317
|
+
const limit = params.body?.size || 10;
|
|
318
|
+
|
|
319
|
+
return await this.searchChemicals(searchTerm, { limit });
|
|
320
|
+
},
|
|
318
321
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const results = await this.searchChemicals(searchTerm, { limit: 10000 });
|
|
329
|
-
return { count: results.results.length };
|
|
330
|
-
}
|
|
322
|
+
count: async (params) => {
|
|
323
|
+
const query = params.body?.query;
|
|
324
|
+
const searchTerm = query?.match?.chemical_name ||
|
|
325
|
+
query?.term?.chemical_name ||
|
|
326
|
+
query?.query_string?.query || '';
|
|
327
|
+
|
|
328
|
+
const results = await this.searchChemicals(searchTerm, { limit: 10000 });
|
|
329
|
+
return { count: results.results.length };
|
|
330
|
+
}
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
333
|
}
|
package/package.json
CHANGED