From e3c4d2abadd98080b9050e0d89228f537dfc08b4 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 17 Jun 2014 16:59:32 +1000 Subject: [PATCH] Bug 12430 - Truncation disables relevance ranking when not using QueryParser 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 "QueryAutoTruncate" 2) Turn off "TryQueryParser" 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. --- C4/Search.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/C4/Search.pm b/C4/Search.pm index 9f39b502f6..fc8b8aa180 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, @@ -1674,7 +1681,6 @@ sub buildQuery { indexes_set => $indexes_set, previous_operand => $previous_operand, }); - } #/if $operands } # /for } -- 2.20.1