@eeplatform/core 1.8.2 → 1.8.4

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/dist/index.mjs CHANGED
@@ -7238,8 +7238,17 @@ function usePSGCRepo() {
7238
7238
  }
7239
7239
  }
7240
7240
  async function getByName({ name, prefix = "", type = "" } = {}) {
7241
- const query = { $text: { $search: name }, type };
7242
- const cacheKeyOptions = { name, type };
7241
+ const stopWords = /* @__PURE__ */ new Set(["of", "the"]);
7242
+ const words = name.trim().split(/\s+/).filter((w) => w.length > 2 && !stopWords.has(w.toLowerCase())).map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
7243
+ const regex = words.map((w) => `(?=.*${w})`).join("");
7244
+ const query = {
7245
+ name: { $regex: regex, $options: "i" }
7246
+ };
7247
+ const cacheKeyOptions = { type };
7248
+ if (type) {
7249
+ query.type = type;
7250
+ cacheKeyOptions.type = type;
7251
+ }
7243
7252
  const _types = ["City", "Mun"];
7244
7253
  if (_types.includes(type)) {
7245
7254
  query.type = { $in: _types };
@@ -7249,6 +7258,10 @@ function usePSGCRepo() {
7249
7258
  cacheKeyOptions.prefix = prefix;
7250
7259
  }
7251
7260
  const cacheKey = makeCacheKey13(namespace_collection, { name });
7261
+ logger19.log({
7262
+ level: "info",
7263
+ message: `Query for getByName PSGC: ${JSON.stringify(query)}`
7264
+ });
7252
7265
  try {
7253
7266
  const cached = await getCache(cacheKey);
7254
7267
  if (cached) {