@infrab4a/connect 4.9.3-beta.12 → 4.9.3

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/index.cjs.js CHANGED
@@ -2501,44 +2501,51 @@ class ProductsIndex {
2501
2501
  filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2502
2502
  if (size > 9)
2503
2503
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2504
+ const query = {
2505
+ should: [
2506
+ {
2507
+ match_phrase: {
2508
+ name: {
2509
+ query: `${searchTerm}`,
2510
+ boost: 4,
2511
+ },
2512
+ },
2513
+ },
2514
+ {
2515
+ match_phrase: {
2516
+ brand: {
2517
+ query: `${searchTerm}`,
2518
+ boost: 2,
2519
+ },
2520
+ },
2521
+ },
2522
+ ],
2523
+ filter,
2524
+ };
2525
+ const complementSearch = searchTerm.split(' ');
2526
+ if (complementSearch.length > 1) {
2527
+ query.should.push({
2528
+ multi_match: {
2529
+ query: `${searchTerm}`,
2530
+ fields: ['name'],
2531
+ operator: 'AND',
2532
+ boost: 3,
2533
+ },
2534
+ }, {
2535
+ match_phrase: {
2536
+ name: {
2537
+ query: `${complementSearch.shift()}`,
2538
+ boost: 1,
2539
+ },
2540
+ },
2541
+ });
2542
+ }
2504
2543
  const search = await this.adapter.query(this.index, {
2505
2544
  size,
2545
+ min_score: 1,
2506
2546
  _source: fields,
2507
2547
  query: {
2508
- bool: {
2509
- should: [
2510
- {
2511
- multi_match: {
2512
- query: `${searchTerm}`,
2513
- fields: ['name', 'name.folded', 'name.search'],
2514
- operator: 'AND',
2515
- },
2516
- },
2517
- {
2518
- match_phrase: {
2519
- name: {
2520
- query: `${searchTerm}`,
2521
- boost: 2,
2522
- },
2523
- },
2524
- },
2525
- {
2526
- match: {
2527
- brand: {
2528
- query: `${searchTerm}`,
2529
- },
2530
- },
2531
- },
2532
- {
2533
- multi_match: {
2534
- query: `${searchTerm}`,
2535
- fields: ['name', 'name.folded', 'name.search'],
2536
- operator: 'OR',
2537
- },
2538
- },
2539
- ],
2540
- filter,
2541
- },
2548
+ bool: query,
2542
2549
  },
2543
2550
  });
2544
2551
  search.hits = search.hits
package/index.esm.js CHANGED
@@ -2495,44 +2495,51 @@ class ProductsIndex {
2495
2495
  filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2496
2496
  if (size > 9)
2497
2497
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2498
+ const query = {
2499
+ should: [
2500
+ {
2501
+ match_phrase: {
2502
+ name: {
2503
+ query: `${searchTerm}`,
2504
+ boost: 4,
2505
+ },
2506
+ },
2507
+ },
2508
+ {
2509
+ match_phrase: {
2510
+ brand: {
2511
+ query: `${searchTerm}`,
2512
+ boost: 2,
2513
+ },
2514
+ },
2515
+ },
2516
+ ],
2517
+ filter,
2518
+ };
2519
+ const complementSearch = searchTerm.split(' ');
2520
+ if (complementSearch.length > 1) {
2521
+ query.should.push({
2522
+ multi_match: {
2523
+ query: `${searchTerm}`,
2524
+ fields: ['name'],
2525
+ operator: 'AND',
2526
+ boost: 3,
2527
+ },
2528
+ }, {
2529
+ match_phrase: {
2530
+ name: {
2531
+ query: `${complementSearch.shift()}`,
2532
+ boost: 1,
2533
+ },
2534
+ },
2535
+ });
2536
+ }
2498
2537
  const search = await this.adapter.query(this.index, {
2499
2538
  size,
2539
+ min_score: 1,
2500
2540
  _source: fields,
2501
2541
  query: {
2502
- bool: {
2503
- should: [
2504
- {
2505
- multi_match: {
2506
- query: `${searchTerm}`,
2507
- fields: ['name', 'name.folded', 'name.search'],
2508
- operator: 'AND',
2509
- },
2510
- },
2511
- {
2512
- match_phrase: {
2513
- name: {
2514
- query: `${searchTerm}`,
2515
- boost: 2,
2516
- },
2517
- },
2518
- },
2519
- {
2520
- match: {
2521
- brand: {
2522
- query: `${searchTerm}`,
2523
- },
2524
- },
2525
- },
2526
- {
2527
- multi_match: {
2528
- query: `${searchTerm}`,
2529
- fields: ['name', 'name.folded', 'name.search'],
2530
- operator: 'OR',
2531
- },
2532
- },
2533
- ],
2534
- filter,
2535
- },
2542
+ bool: query,
2536
2543
  },
2537
2544
  });
2538
2545
  search.hits = search.hits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.3-beta.12",
3
+ "version": "4.9.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "class-transformer": "^0.5.1",
14
14
  "date-fns": "^2.28.0",
15
15
  "debug": "^4.3.4",
16
- "firebase": "^10.12.0",
16
+ "firebase": "^9.23.0",
17
17
  "gql-query-builder": "3.7.0",
18
18
  "lodash": "^4.17.21",
19
19
  "reflect-metadata": "^0.1.13",
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
5
5
  export declare const withHelpers: <TMixinBase extends MixinCtor = MixinCtor>(MixinBase: MixinCtor & TMixinBase) => {
6
6
  new (...args: any[]): {
7
7
  [x: string]: any;
8
- toArray<T extends ModelBaseStructure<T>>(snapShot: QuerySnapshot<T, import("@firebase/firestore").DocumentData> | QueryDocumentSnapshot<T, import("@firebase/firestore").DocumentData>[]): T[];
8
+ toArray<T extends ModelBaseStructure<T>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
9
9
  isSubCollection<T_1 extends ModelBaseStructure<T_1>, E extends ModelBaseStructure<E>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
10
10
  };
11
11
  } & TMixinBase;