From 3f0e4c7d5784fd59b6924942e3454db8e9c1b31f Mon Sep 17 00:00:00 2001 From: indy koning Date: Wed, 15 Oct 2025 11:18:47 +0200 Subject: [PATCH 1/5] Moved relevance query to default query value --- resources/js/components/Listing/Listing.vue | 18 ++++-------------- .../components/Search/InstantSearchMixin.vue | 19 +++++++++++++++++++ resources/js/package.js | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/resources/js/components/Listing/Listing.vue b/resources/js/components/Listing/Listing.vue index e055b95d0..050c583e5 100644 --- a/resources/js/components/Listing/Listing.vue +++ b/resources/js/components/Listing/Listing.vue @@ -9,10 +9,6 @@ export default { type: String, default: window.config.index.product, }, - query: { - type: Function, - default: () => [], - }, categoryId: { type: Number, }, @@ -101,7 +97,6 @@ export default { const config = await InstantSearchMixin.methods.getInstantSearchClientConfig.bind(this).call() config.getBaseFilters = this.getBaseFilters - config.getQuery = this.getQuery return config }, @@ -138,19 +133,14 @@ export default { return this.baseFilters().concat(extraFilters) }, - getQuery(query, search_attributes) { - let extraQueries = [] + getQuery(query, search_attributes, config) { + let queries = InstantSearchMixin.methods.getQuery.bind(this).call(this, ...arguments) if (this.categoryId) { - extraQueries.push(this.$root.categoryPositions(this.categoryId)) - } - - // __NO_QUERY__ is a temporary band-aid for https://github.com/searchkit/searchkit/pull/1407 - if (query && query !== '__NO_QUERY__') { - extraQueries.push(this.relevanceQueryMatch(query, search_attributes, config?.fuzziness)) + queries.push(this.$root.categoryPositions(this.categoryId)) } - return this.query().concat(extraQueries) + return queries }, windowTitle(routeState) { diff --git a/resources/js/components/Search/InstantSearchMixin.vue b/resources/js/components/Search/InstantSearchMixin.vue index 328c007e1..aa92f59c8 100644 --- a/resources/js/components/Search/InstantSearchMixin.vue +++ b/resources/js/components/Search/InstantSearchMixin.vue @@ -5,6 +5,17 @@ import { instantsearchMiddlewares } from '../../stores/useInstantsearchMiddlewar import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares/createInsightsMiddleware' export default { + props: { + query: { + type: Function, + default: function (query, searchAttributes, config) { + // __NO_QUERY__ is a temporary band-aid for https://github.com/searchkit/searchkit/pull/1407 + if (query && query !== '__NO_QUERY__') { + return this.relevanceQueryMatch(query, searchAttributes, config?.fuzziness) + } + }, + }, + }, data: () => ({ searchkit: null, searchClient: null, @@ -45,6 +56,7 @@ export default { }) }, }, + getQuery: this.getQuery } }, @@ -56,6 +68,13 @@ export default { return instantsearchMiddlewares }, + getQuery(query, search_attributes, config) { + const esQuery = this.query(...arguments); + let queries = Array.isArray(esQuery) ? esQuery : [esQuery]; + + return queries.filter((q) => q) + }, + relevanceQueryMatch(query, search_attributes, fuzziness = 'AUTO:4,8') { // Copied from searchkit.js default behavior when getQuery is not defined. const getFieldsMap = (boostMultiplier) => { diff --git a/resources/js/package.js b/resources/js/package.js index ec870372f..e73e84e88 100644 --- a/resources/js/package.js +++ b/resources/js/package.js @@ -135,7 +135,7 @@ function init() { function_score: { script_score: { script: { - source: `doc.containsKey('positions.${categoryId}') ? (Integer.parseInt(doc['positions.${categoryId}'].empty ? '0' : doc['positions.${categoryId}'].value)) : 0`, + source: `doc.containsKey('positions.${categoryId}') ? ((doc['positions.${categoryId}'].empty || !/^\d+$/.matcher(doc['positions.${categoryId}'].value).matches()) ? 0 : Integer.parseInt(doc['positions.${categoryId}'].value)) : 0`, }, }, }, From 70f667dc5795bec67cb67747318e39d3f116aaf5 Mon Sep 17 00:00:00 2001 From: indykoning Date: Wed, 15 Oct 2025 09:19:39 +0000 Subject: [PATCH 2/5] Apply fixes from Prettier --- resources/js/components/Search/InstantSearchMixin.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/js/components/Search/InstantSearchMixin.vue b/resources/js/components/Search/InstantSearchMixin.vue index aa92f59c8..55b84362c 100644 --- a/resources/js/components/Search/InstantSearchMixin.vue +++ b/resources/js/components/Search/InstantSearchMixin.vue @@ -56,7 +56,7 @@ export default { }) }, }, - getQuery: this.getQuery + getQuery: this.getQuery, } }, @@ -69,8 +69,8 @@ export default { }, getQuery(query, search_attributes, config) { - const esQuery = this.query(...arguments); - let queries = Array.isArray(esQuery) ? esQuery : [esQuery]; + const esQuery = this.query(...arguments) + let queries = Array.isArray(esQuery) ? esQuery : [esQuery] return queries.filter((q) => q) }, From ec7d294d62ab7cf1094d1686d881a5dd0b3c73ee Mon Sep 17 00:00:00 2001 From: indykoning Date: Wed, 15 Oct 2025 09:40:03 +0000 Subject: [PATCH 3/5] [CI] Update Snapshots --- ...egory-with-configurable-products-1-Mobile-Chrome-linux.png | 4 ++-- ...egory-with-configurable-products-1-Mobile-Safari-linux.png | 4 ++-- .../category-with-configurable-products-1-chromium-linux.png | 4 ++-- .../category-with-configurable-products-1-firefox-linux.png | 4 ++-- .../category-with-configurable-products-1-webkit-linux.png | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png index 0a53165dc..65cfb06cf 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7c101cf194bfa0deb31f1a149d5a0aa3bfb6dcd16f4efb62b1eca1356b7d771 -size 512515 +oid sha256:6282b80e500a1c654738ca4bf2772a5a1ac339d5e7432584fc4442eb8ca65a74 +size 536482 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png index da404a145..32e1d75dd 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89668c46173ec59f099e57361edc74477dcc80e82da61e53c19f0884e8cee3bb -size 557451 +oid sha256:0d5c9072c0edf40ae19f07d709a9216c86b1aca9a66c81ce0c04ea3c812eade2 +size 584302 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png index b9894a1c9..4b9bae938 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8c8d17fa785669ef7f35c2daa5416b129b88ff24c5721333bdc2de0bdc55568 -size 587759 +oid sha256:20cc319ed30cf197851db2b85c3a917857ecdf063b1b0bcf47691ee8bbbab2af +size 606802 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png index 85efc6896..4e1f0a0ad 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b7568a2cee6e006dd09b8b50bee64b37e61e3ecdc3c52472577814aa10aa945b -size 870495 +oid sha256:ce9bed42f136a75b488beb56aacb5fc65c00ca7e4c748fe2e63663ad32962dcd +size 876725 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png index 200066448..15f10d44f 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9ac6f184c809da41fe4f7950fa5425915965dd33b9b128a04ae5caf2ff98239 -size 662841 +oid sha256:d1e41ead20032991c540264e1657f199ccf0073b8df28f6fdc8abeb6178f0734 +size 684398 From 4a7b196a0536313498a0c5c7abc0951a70fa282c Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 15 Oct 2025 11:45:12 +0200 Subject: [PATCH 4/5] Discard changes to resources/js/package.js --- resources/js/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/package.js b/resources/js/package.js index e73e84e88..ec870372f 100644 --- a/resources/js/package.js +++ b/resources/js/package.js @@ -135,7 +135,7 @@ function init() { function_score: { script_score: { script: { - source: `doc.containsKey('positions.${categoryId}') ? ((doc['positions.${categoryId}'].empty || !/^\d+$/.matcher(doc['positions.${categoryId}'].value).matches()) ? 0 : Integer.parseInt(doc['positions.${categoryId}'].value)) : 0`, + source: `doc.containsKey('positions.${categoryId}') ? (Integer.parseInt(doc['positions.${categoryId}'].empty ? '0' : doc['positions.${categoryId}'].value)) : 0`, }, }, }, From 69d5587223abd2231dd06267a1bf413e79ddd07f Mon Sep 17 00:00:00 2001 From: indykoning Date: Wed, 15 Oct 2025 10:00:44 +0000 Subject: [PATCH 5/5] [CI] Update Snapshots --- ...egory-with-configurable-products-1-Mobile-Chrome-linux.png | 4 ++-- ...egory-with-configurable-products-1-Mobile-Safari-linux.png | 4 ++-- .../category-with-configurable-products-1-chromium-linux.png | 4 ++-- .../category-with-configurable-products-1-firefox-linux.png | 4 ++-- .../category-with-configurable-products-1-webkit-linux.png | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png index 65cfb06cf..0a53165dc 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Chrome-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6282b80e500a1c654738ca4bf2772a5a1ac339d5e7432584fc4442eb8ca65a74 -size 536482 +oid sha256:d7c101cf194bfa0deb31f1a149d5a0aa3bfb6dcd16f4efb62b1eca1356b7d771 +size 512515 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png index 32e1d75dd..da404a145 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-Mobile-Safari-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d5c9072c0edf40ae19f07d709a9216c86b1aca9a66c81ce0c04ea3c812eade2 -size 584302 +oid sha256:89668c46173ec59f099e57361edc74477dcc80e82da61e53c19f0884e8cee3bb +size 557451 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png index 4b9bae938..b9894a1c9 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-chromium-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20cc319ed30cf197851db2b85c3a917857ecdf063b1b0bcf47691ee8bbbab2af -size 606802 +oid sha256:f8c8d17fa785669ef7f35c2daa5416b129b88ff24c5721333bdc2de0bdc55568 +size 587759 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png index 4e1f0a0ad..85efc6896 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-firefox-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce9bed42f136a75b488beb56aacb5fc65c00ca7e4c748fe2e63663ad32962dcd -size 876725 +oid sha256:b7568a2cee6e006dd09b8b50bee64b37e61e3ecdc3c52472577814aa10aa945b +size 870495 diff --git a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png index 15f10d44f..200066448 100644 --- a/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png +++ b/tests/playwright/category.spec.js-snapshots/category-with-configurable-products-1-webkit-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d1e41ead20032991c540264e1657f199ccf0073b8df28f6fdc8abeb6178f0734 -size 684398 +oid sha256:e9ac6f184c809da41fe4f7950fa5425915965dd33b9b128a04ae5caf2ff98239 +size 662841