@infrab4a/connect 3.9.0-beta.5 → 3.9.0-beta.6
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/bundles/infrab4a-connect.umd.js +48 -23
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +44 -20
- package/fesm2015/infrab4a-connect.js +42 -18
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/elasticsearch/indexes/products-index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1899,38 +1899,63 @@
|
|
|
1899
1899
|
});
|
|
1900
1900
|
});
|
|
1901
1901
|
};
|
|
1902
|
-
ProductsIndex.prototype.search = function (searchTerm) {
|
|
1902
|
+
ProductsIndex.prototype.search = function (searchTerm, total, shop) {
|
|
1903
1903
|
return __awaiter(this, void 0, void 0, function () {
|
|
1904
|
-
var search;
|
|
1904
|
+
var size, fields, filter, search;
|
|
1905
1905
|
return __generator(this, function (_a) {
|
|
1906
1906
|
switch (_a.label) {
|
|
1907
|
-
case 0:
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1907
|
+
case 0:
|
|
1908
|
+
size = total >= 10 ? 500 : 9;
|
|
1909
|
+
fields = [
|
|
1910
|
+
'EAN',
|
|
1911
|
+
'brand',
|
|
1912
|
+
'id',
|
|
1913
|
+
'images',
|
|
1914
|
+
'miniatures',
|
|
1915
|
+
'name',
|
|
1916
|
+
'price',
|
|
1917
|
+
'sku',
|
|
1918
|
+
'stock',
|
|
1919
|
+
'slug',
|
|
1920
|
+
'reviews',
|
|
1921
|
+
'hasVariants',
|
|
1922
|
+
'rate',
|
|
1923
|
+
];
|
|
1924
|
+
filter = [{ term: { published: true } }];
|
|
1925
|
+
if (size > 9) {
|
|
1926
|
+
fields.push.apply(fields, ['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
1927
|
+
}
|
|
1928
|
+
else {
|
|
1929
|
+
filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
1930
|
+
}
|
|
1931
|
+
return [4 /*yield*/, this.adapter.query(this.index, {
|
|
1932
|
+
body: {
|
|
1933
|
+
size: size,
|
|
1934
|
+
_source: fields,
|
|
1935
|
+
query: {
|
|
1936
|
+
bool: {
|
|
1937
|
+
must: {
|
|
1938
|
+
multi_match: {
|
|
1939
|
+
query: "" + searchTerm,
|
|
1940
|
+
fields: ['name', 'name.folded', 'name.search', 'description', 'brand'],
|
|
1941
|
+
fuzziness: 2,
|
|
1942
|
+
},
|
|
1943
|
+
},
|
|
1944
|
+
should: {
|
|
1945
|
+
match_phrase_prefix: {
|
|
1946
|
+
'name.search': {
|
|
1947
|
+
query: "" + searchTerm,
|
|
1948
|
+
slop: 10,
|
|
1949
|
+
},
|
|
1950
|
+
},
|
|
1922
1951
|
},
|
|
1952
|
+
filter: filter,
|
|
1923
1953
|
},
|
|
1924
1954
|
},
|
|
1925
|
-
filter: [{ term: { published: true } }],
|
|
1926
1955
|
},
|
|
1927
|
-
}
|
|
1928
|
-
})];
|
|
1956
|
+
})];
|
|
1929
1957
|
case 1:
|
|
1930
1958
|
search = _a.sent();
|
|
1931
|
-
search.hits.forEach(function (row) {
|
|
1932
|
-
row._source.price = Object.assign(Object.assign({}, row._source.price), (!!row._source.price.Glamshop && row._source.price.Glamshop));
|
|
1933
|
-
});
|
|
1934
1959
|
search.hits = search.hits.filter(function (e) { return e._source.name !== ''; });
|
|
1935
1960
|
return [2 /*return*/, search];
|
|
1936
1961
|
}
|