@infrab4a/connect 4.9.3-beta.2 → 4.9.4-beta.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/index.cjs.js CHANGED
@@ -2641,44 +2641,84 @@ class ProductsIndex {
2641
2641
  filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2642
2642
  if (size > 9)
2643
2643
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2644
+ const query = {
2645
+ should: [
2646
+ {
2647
+ match_phrase: {
2648
+ name: {
2649
+ query: `${searchTerm}`,
2650
+ boost: 3,
2651
+ },
2652
+ },
2653
+ },
2654
+ {
2655
+ match: {
2656
+ brand: {
2657
+ query: `${searchTerm}`,
2658
+ boost: 2,
2659
+ },
2660
+ },
2661
+ },
2662
+ ],
2663
+ filter,
2664
+ };
2665
+ const complementSearch = searchTerm.split(' ');
2666
+ if (complementSearch.length > 1) {
2667
+ query.should.push({
2668
+ match_phrase: {
2669
+ name: {
2670
+ query: `${complementSearch.shift()}`,
2671
+ boost: 1,
2672
+ },
2673
+ },
2674
+ }, {
2675
+ multi_match: {
2676
+ query: `${searchTerm}`,
2677
+ fields: ['name'],
2678
+ operator: 'AND',
2679
+ boost: 2,
2680
+ },
2681
+ });
2682
+ }
2644
2683
  const search = await this.adapter.query(this.index, {
2645
2684
  size,
2646
2685
  _source: fields,
2647
2686
  query: {
2648
- bool: {
2649
- should: [
2650
- {
2651
- multi_match: {
2652
- query: `${searchTerm}`,
2653
- fields: ['name', 'name.folded', 'name.search'],
2654
- operator: 'AND',
2655
- },
2656
- },
2657
- {
2658
- match_phrase: {
2659
- name: {
2660
- query: `${searchTerm}`,
2661
- boost: 2,
2662
- },
2663
- },
2664
- },
2665
- {
2666
- match: {
2667
- brand: {
2668
- query: `${searchTerm}`,
2669
- },
2670
- },
2671
- },
2672
- {
2673
- multi_match: {
2674
- query: `${searchTerm}`,
2675
- fields: ['name', 'name.folded', 'name.search'],
2676
- operator: 'OR',
2677
- },
2678
- },
2679
- ],
2680
- filter,
2681
- },
2687
+ bool: query,
2688
+ // {
2689
+ // should: [
2690
+ // {
2691
+ // multi_match: {
2692
+ // query: `${searchTerm}`,
2693
+ // fields: ['name', 'name.folded', 'name.search'],
2694
+ // operator: 'AND',
2695
+ // },
2696
+ // },
2697
+ // {
2698
+ // match_phrase: {
2699
+ // name: {
2700
+ // query: `${searchTerm}`,
2701
+ // boost: 2,
2702
+ // },
2703
+ // },
2704
+ // },
2705
+ // {
2706
+ // match: {
2707
+ // brand: {
2708
+ // query: `${searchTerm}`,
2709
+ // },
2710
+ // },
2711
+ // },
2712
+ // {
2713
+ // multi_match: {
2714
+ // query: `${searchTerm}`,
2715
+ // fields: ['name', 'name.folded', 'name.search'],
2716
+ // operator: 'OR',
2717
+ // },
2718
+ // },
2719
+ // ],
2720
+ // filter,
2721
+ // },
2682
2722
  },
2683
2723
  });
2684
2724
  search.hits = search.hits
@@ -4888,7 +4928,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4888
4928
  },
4889
4929
  'theme',
4890
4930
  { bannerUrl: { columnName: 'banner_url' } },
4891
- { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4892
4931
  ],
4893
4932
  });
4894
4933
  this.productRepository = productRepository;
package/index.esm.js CHANGED
@@ -2617,44 +2617,84 @@ class ProductsIndex {
2617
2617
  filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
2618
2618
  if (size > 9)
2619
2619
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
2620
+ const query = {
2621
+ should: [
2622
+ {
2623
+ match_phrase: {
2624
+ name: {
2625
+ query: `${searchTerm}`,
2626
+ boost: 3,
2627
+ },
2628
+ },
2629
+ },
2630
+ {
2631
+ match: {
2632
+ brand: {
2633
+ query: `${searchTerm}`,
2634
+ boost: 2,
2635
+ },
2636
+ },
2637
+ },
2638
+ ],
2639
+ filter,
2640
+ };
2641
+ const complementSearch = searchTerm.split(' ');
2642
+ if (complementSearch.length > 1) {
2643
+ query.should.push({
2644
+ match_phrase: {
2645
+ name: {
2646
+ query: `${complementSearch.shift()}`,
2647
+ boost: 1,
2648
+ },
2649
+ },
2650
+ }, {
2651
+ multi_match: {
2652
+ query: `${searchTerm}`,
2653
+ fields: ['name'],
2654
+ operator: 'AND',
2655
+ boost: 2,
2656
+ },
2657
+ });
2658
+ }
2620
2659
  const search = await this.adapter.query(this.index, {
2621
2660
  size,
2622
2661
  _source: fields,
2623
2662
  query: {
2624
- bool: {
2625
- should: [
2626
- {
2627
- multi_match: {
2628
- query: `${searchTerm}`,
2629
- fields: ['name', 'name.folded', 'name.search'],
2630
- operator: 'AND',
2631
- },
2632
- },
2633
- {
2634
- match_phrase: {
2635
- name: {
2636
- query: `${searchTerm}`,
2637
- boost: 2,
2638
- },
2639
- },
2640
- },
2641
- {
2642
- match: {
2643
- brand: {
2644
- query: `${searchTerm}`,
2645
- },
2646
- },
2647
- },
2648
- {
2649
- multi_match: {
2650
- query: `${searchTerm}`,
2651
- fields: ['name', 'name.folded', 'name.search'],
2652
- operator: 'OR',
2653
- },
2654
- },
2655
- ],
2656
- filter,
2657
- },
2663
+ bool: query,
2664
+ // {
2665
+ // should: [
2666
+ // {
2667
+ // multi_match: {
2668
+ // query: `${searchTerm}`,
2669
+ // fields: ['name', 'name.folded', 'name.search'],
2670
+ // operator: 'AND',
2671
+ // },
2672
+ // },
2673
+ // {
2674
+ // match_phrase: {
2675
+ // name: {
2676
+ // query: `${searchTerm}`,
2677
+ // boost: 2,
2678
+ // },
2679
+ // },
2680
+ // },
2681
+ // {
2682
+ // match: {
2683
+ // brand: {
2684
+ // query: `${searchTerm}`,
2685
+ // },
2686
+ // },
2687
+ // },
2688
+ // {
2689
+ // multi_match: {
2690
+ // query: `${searchTerm}`,
2691
+ // fields: ['name', 'name.folded', 'name.search'],
2692
+ // operator: 'OR',
2693
+ // },
2694
+ // },
2695
+ // ],
2696
+ // filter,
2697
+ // },
2658
2698
  },
2659
2699
  });
2660
2700
  search.hits = search.hits
@@ -4864,7 +4904,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4864
4904
  },
4865
4905
  'theme',
4866
4906
  { bannerUrl: { columnName: 'banner_url' } },
4867
- { mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
4868
4907
  ],
4869
4908
  });
4870
4909
  this.productRepository = productRepository;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.3-beta.2",
3
+ "version": "4.9.4-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -26,7 +26,6 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
26
26
  parentId?: number;
27
27
  theme?: string;
28
28
  bannerUrl?: string;
29
- mostRelevant?: string[];
30
29
  parent?: CategoryBase;
31
30
  filters?: Filter[];
32
31
  static get identifiersFields(): GenericIdentifier[];