From 455ebc5c02657a6c1c328977e08176e222c56ddd Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 5 Aug 2024 13:12:22 +0700 Subject: query filter --- src/pages/api/shop/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pages/api/shop/search.js') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index b6b8c795..29471f7b 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -39,7 +39,7 @@ export default async function handler(req, res) { paramOrderBy += 'flashsale_price_f ASC'; break; default: - paramOrderBy += 'product_rating_f DESC, price_discount_f DESC'; + paramOrderBy += ''; break; } @@ -56,7 +56,7 @@ export default async function handler(req, res) { `start=${parseInt(offset)}`, `rows=${limit}`, `sort=${paramOrderBy}`, - `fq=-publish_b:false`, + `fq=-publish_b:false, product_rating_f:[13 TO *], discount_tier1_v2_f:[1 TO *]`, ]; if (priceFrom > 0 || priceTo > 0) { -- cgit v1.2.3 From e26e9b44c88cf6cf76ba3ab1d8e8408bf45c61ca Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Wed, 7 Aug 2024 10:35:54 +0700 Subject: cr fq solr search --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pages/api/shop/search.js') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 29471f7b..5c2d4ffc 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -56,7 +56,7 @@ export default async function handler(req, res) { `start=${parseInt(offset)}`, `rows=${limit}`, `sort=${paramOrderBy}`, - `fq=-publish_b:false, product_rating_f:[13 TO *], discount_tier1_v2_f:[1 TO *]`, + `fq=-publish_b:false, product_rating_f:[13 TO *], price_tier1_v2_f:[1 TO *]`, ]; if (priceFrom > 0 || priceTo > 0) { -- cgit v1.2.3 From af15f29e8e057b338cbf9d8264edf703a7d624e6 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 8 Aug 2024 08:35:52 +0700 Subject: cr query filter product rating --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pages/api/shop/search.js') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 5c2d4ffc..d5a7ab31 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -56,7 +56,7 @@ export default async function handler(req, res) { `start=${parseInt(offset)}`, `rows=${limit}`, `sort=${paramOrderBy}`, - `fq=-publish_b:false, product_rating_f:[13 TO *], price_tier1_v2_f:[1 TO *]`, + `fq=-publish_b:false, product_rating_f:[8 TO *], price_tier1_v2_f:[1 TO *]`, ]; if (priceFrom > 0 || priceTo > 0) { -- cgit v1.2.3 From 0b7db052b04ab983632463232fc8190a6f69143a Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 8 Aug 2024 15:06:27 +0700 Subject: update q --- src/pages/api/shop/search.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/pages/api/shop/search.js') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index d5a7ab31..b886985c 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -42,7 +42,10 @@ export default async function handler(req, res) { paramOrderBy += ''; break; } - + + let checkQ = q.trim().split(/\s+/); + let newQ = checkQ.length > 1 ? escapeSolrQuery(q) + '*' : escapeSolrQuery(q); + let offset = (page - 1) * limit; let parameter = [ 'facet.field=manufacture_name_s', @@ -51,7 +54,7 @@ export default async function handler(req, res) { 'indent=true', `facet.query=${escapeSolrQuery(q)}`, `q.op=${operation}`, - `q=${escapeSolrQuery(q)}`, + `q=${newQ}`, 'qf=name_s', `start=${parseInt(offset)}`, `rows=${limit}`, @@ -77,7 +80,10 @@ export default async function handler(req, res) { parameter.push( `fq=${brand .split(',') - .map((manufacturer) => `manufacture_name:"${encodeURIComponent(manufacturer)}"`) + .map( + (manufacturer) => + `manufacture_name:"${encodeURIComponent(manufacturer)}"` + ) .join(' OR ')}` ); if (category) -- cgit v1.2.3 From a0c053de428bcf40a8435921023290a56bd7d8ea Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 9 Aug 2024 14:28:01 +0700 Subject: tunning uqery for sku --- src/pages/api/shop/search.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/pages/api/shop/search.js') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index b886985c..6f98efcb 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -43,7 +43,7 @@ export default async function handler(req, res) { break; } - let checkQ = q.trim().split(/\s+/); + let checkQ = q.trim().split(/[\s\+\-\!\(\)\{\}\[\]\^"~\*\?:\\\/]+/); let newQ = checkQ.length > 1 ? escapeSolrQuery(q) + '*' : escapeSolrQuery(q); let offset = (page - 1) * limit; @@ -126,12 +126,14 @@ export default async function handler(req, res) { const escapeSolrQuery = (query) => { if (query == '*') return query; + + query = query.replace(/-/g, ' '); - const specialChars = /([\+\-\!\(\)\{\}\[\]\^"~\*\?:\\\/])/g; + const specialChars = /([\+\!\(\)\{\}\[\]\^"~\*\?:\\\/])/g; const words = query.split(/\s+/); const escapedWords = words.map((word) => { if (specialChars.test(word)) { - return `"${word.replace(specialChars, '\\$1')}"`; + return word.replace(specialChars, '\\$1'); } return word; }); @@ -139,6 +141,7 @@ const escapeSolrQuery = (query) => { return escapedWords.join(' '); }; + /*const productResponseMap = (products, pricelist) => { return products.map((product) => { let price = product.price_tier1_v2_f || 0 -- cgit v1.2.3