diff --git a/api/result_formatter.py b/api/result_formatter.py index 2300325..936bb0a 100644 --- a/api/result_formatter.py +++ b/api/result_formatter.py @@ -184,7 +184,7 @@ class ResultFormatter: filter_field = 'option2_value' elif option3_name and option3_name.lower() == dimension_lower: filter_field = 'option3_value' - + # If no matching field found, return all SKUs (no filtering) if not filter_field: return skus diff --git a/docs/常用查询 - ES.md b/docs/常用查询 - ES.md index 2c9c0fe..036da29 100644 --- a/docs/常用查询 - ES.md +++ b/docs/常用查询 - ES.md @@ -17,4 +17,19 @@ curl -u 'essa:4hOaLaf41y2VuI8y' -X GET 'http://localhost:9200/search_products/ ] } } - }' \ No newline at end of file + }' + + + +curl -u 'essa:4hOaLaf41y2VuI8y' -X GET 'http://localhost:9200/search_products/_search?pretty' -H 'Content-Type: application/json' -d '{ + "size": 5, + "query": { + "bool": { + "filter": [ + { "term": { "spu_id": "74123" } } + ] + } + } + }' + + diff --git a/frontend/index.html b/frontend/index.html index bcb736c..5d579f7 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -25,6 +25,10 @@ +
+ + +
@@ -131,6 +135,6 @@

SearchEngine © 2025 | API: Loading...

- + diff --git a/frontend/static/css/style.css b/frontend/static/css/style.css index c9b9ba7..f2ab340 100644 --- a/frontend/static/css/style.css +++ b/frontend/static/css/style.css @@ -84,7 +84,8 @@ body { white-space: nowrap; } -#tenantInput { +#tenantInput, +#skuFilterDimension { width: 120px; padding: 10px 15px; font-size: 14px; @@ -93,7 +94,8 @@ body { outline: none; } -#tenantInput:focus { +#tenantInput:focus, +#skuFilterDimension:focus { border-color: #e74c3c; } diff --git a/frontend/static/js/app.js b/frontend/static/js/app.js index 71b7cf2..de9e667 100644 --- a/frontend/static/js/app.js +++ b/frontend/static/js/app.js @@ -14,6 +14,17 @@ function getTenantId() { return '1'; // Default fallback } +// Get sku_filter_dimension from input +function getSkuFilterDimension() { + const skuFilterInput = document.getElementById('skuFilterDimension'); + if (skuFilterInput) { + const value = skuFilterInput.value.trim(); + // Return the value if not empty, otherwise return null + return value.length > 0 ? value : null; + } + return null; +} + // State Management let state = { query: '', @@ -51,6 +62,7 @@ function toggleFilters() { async function performSearch(page = 1) { const query = document.getElementById('searchInput').value.trim(); const tenantId = getTenantId(); + const skuFilterDimension = getSkuFilterDimension(); if (!query) { alert('Please enter search keywords'); @@ -96,6 +108,7 @@ async function performSearch(page = 1) { facets: facets, sort_by: state.sortBy || null, sort_order: state.sortOrder, + sku_filter_dimension: skuFilterDimension, debug: state.debug }) }); -- libgit2 0.21.2