@toxplanet/pegasus-sdk 1.2.11 → 1.2.12

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.
Files changed (2) hide show
  1. package/lib/chemicals.js +13 -3
  2. package/package.json +1 -1
package/lib/chemicals.js CHANGED
@@ -1305,7 +1305,7 @@ class ChemicalsService {
1305
1305
  search: async (params) => {
1306
1306
  let searchTerm = '';
1307
1307
  let limit = params.body?.size || 10;
1308
-
1308
+
1309
1309
  const toLegacySource = (r) => this._toLegacyChemicalSource({
1310
1310
  name: r.name,
1311
1311
  cas: r.cas || [],
@@ -1313,11 +1313,21 @@ class ChemicalsService {
1313
1313
  id: r.id
1314
1314
  });
1315
1315
 
1316
+ // Callers may pass an Elasticsearch query_string with reserved chars escaped
1317
+ // (e.g. "71\-43\-2"). Strip the escapes plus a trailing wildcard so keyword
1318
+ // term/prefix clauses against cas_numbers / identifier_values can match.
1319
+ const normalizeQueryString = (raw) => {
1320
+ if (!raw) return '';
1321
+ let s = String(raw);
1322
+ if (s.endsWith('*')) s = s.slice(0, -1);
1323
+ return s.replace(/\\(.)/g, '$1');
1324
+ };
1325
+
1316
1326
  if (params.index === 'synonym_lookup_index') {
1317
1327
  const query = params.body?.query;
1318
1328
  searchTerm = query?.match?.chemical_name ||
1319
1329
  query?.term?.chemical_name ||
1320
- query?.query_string?.query || '';
1330
+ normalizeQueryString(query?.query_string?.query) || '';
1321
1331
  const searchResults = await this.searchBySynonym(searchTerm, limit);
1322
1332
 
1323
1333
  return {
@@ -1347,7 +1357,7 @@ class ChemicalsService {
1347
1357
  const query = params.body?.query;
1348
1358
  searchTerm = query?.match?.chemical_name ||
1349
1359
  query?.term?.chemical_name ||
1350
- query?.query_string?.query || '';
1360
+ normalizeQueryString(query?.query_string?.query) || '';
1351
1361
  const searchResults = await this.searchByName(searchTerm, limit);
1352
1362
 
1353
1363
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toxplanet/pegasus-sdk",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "SDK for migrating chemical data to Pegasus PostgreSQL + OpenSearch architecture with Elasticsearch client compatibility",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",