From 21173ef606e6d8e9548ca33b063cf78d78520c30 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 17 Jun 2014 16:59:32 +1000 Subject: [PATCH] Bug 12430: Use releance ranking without QueryWeightFields The system preference "QueryWeightFields" is mutually exclusive with the system preference "QueryAutoTruncate" and the * truncation modifier, when not using QueryParser. If you use truncation, relevance won't work anymore. (N.B. Relevance doesn't work probably when using QueryParser, but for a very different reason beyond the current scope of this bug.) This patch adds relevance ranking when using truncation (or basically when QueryWeightFields is disabled). _TEST PLAN_ 1) Turn on "QueryWeightFields" and set "QueryAutoTruncate" to auto 2) Turn off "UseQueryParser" 3) Do a keyword search in the OPAC 4) Note that the results are ordered by biblionumber ascending 5) Apply patch 6) Do the same keyword search in the OPAC 7) Note that the results are never ordered differently (presumably in relevance order :P) If you're a stickler, throw in some warns so that you can see what CCL query is being sent to Zebra. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit f6b5dfa4b718fb74654448b5663cb264b5c376b7) Signed-off-by: Fridolin Somers (cherry picked from commit 913cf92b2d8d4b1a948e32c941c903359afa7f02) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit 66b76dd33d623cc6165cab8a2a6c8f71f28834e3) Signed-off-by: Victor Grousset/tuxayo --- C4/Search.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/Search.pm b/C4/Search.pm index 11b755e364..a866b7bd20 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1662,6 +1662,13 @@ sub buildQuery { warn "FIELD WEIGHTED OPERAND: >$weighted_operand<" if $DEBUG; + #Use relevance ranking when not using a weighted query (which adds relevance ranking of its own) + + #N.B. Truncation is mutually exclusive with Weighted Queries, + #so even if QueryWeightFields is turned on, QueryAutoTruncate will turn it off, thus + #the need for this relevance wrapper. + $operand = "(rk=($operand))" unless $weight_fields; + ($query,$query_cgi,$query_desc,$previous_operand) = _build_initial_query({ query => $query, query_cgi => $query_cgi, -- 2.39.5