From 25159935365d6d39854fd63eb02cc160717923ee Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Thu, 15 Feb 2024 13:52:11 +0100 Subject: [PATCH] (search) Fix issue where searchTitle setting gets lost when searching again It's important that the field names in SearchParameters matches the fields referenced in search-form.hdb, otherwise they will get lost in transit. --- .../search/command/SearchParameters.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/command/SearchParameters.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/command/SearchParameters.java index 7a55c1cc..5b2df90e 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/command/SearchParameters.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/command/SearchParameters.java @@ -14,7 +14,7 @@ public record SearchParameters(String query, SearchProfile profile, SearchJsParameter js, SearchRecentParameter recent, - SearchTitleParameter title, + SearchTitleParameter searchTitle, SearchAdtechParameter adtech ) { public String profileStr() { @@ -22,18 +22,18 @@ public record SearchParameters(String query, } public SearchParameters withProfile(SearchProfile profile) { - return new SearchParameters(query, profile, js, recent, title, adtech); + return new SearchParameters(query, profile, js, recent, searchTitle, adtech); } public SearchParameters withJs(SearchJsParameter js) { - return new SearchParameters(query, profile, js, recent, title, adtech); + return new SearchParameters(query, profile, js, recent, searchTitle, adtech); } public SearchParameters withAdtech(SearchAdtechParameter adtech) { - return new SearchParameters(query, profile, js, recent, title, adtech); + return new SearchParameters(query, profile, js, recent, searchTitle, adtech); } public SearchParameters withRecent(SearchRecentParameter recent) { - return new SearchParameters(query, profile, js, recent, title, adtech); + return new SearchParameters(query, profile, js, recent, searchTitle, adtech); } public SearchParameters withTitle(SearchTitleParameter title) { @@ -47,7 +47,7 @@ public record SearchParameters(String query, URLEncoder.encode(js.value, StandardCharsets.UTF_8), URLEncoder.encode(adtech.value, StandardCharsets.UTF_8), URLEncoder.encode(recent.value, StandardCharsets.UTF_8), - URLEncoder.encode(title.value, StandardCharsets.UTF_8) + URLEncoder.encode(searchTitle.value, StandardCharsets.UTF_8) ); return baseUrl.withPath(path); @@ -65,7 +65,7 @@ public record SearchParameters(String query, } public QueryStrategy strategy() { - if (title == SearchTitleParameter.TITLE) { + if (searchTitle == SearchTitleParameter.TITLE) { return QueryStrategy.REQUIRE_FIELD_TITLE; }