From 39bf1c502aec95742c81f43d7d631223b399ce5b Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Mon, 11 Feb 2013 14:47:09 +0100 Subject: [PATCH] Bug 9588: weighted search query with index When QueryWeightFields is enabled, the searching query is created with several options. In C4::Search::_build_weighted_query, when no index is defined, the query is build with fuzzy and stemming options. When an index is defined, theses options are missing, only unconditional right truncation is used. The consequence is that when QueryStemming is disabled, a search with index can give more results (due to right truncation) that a search without. This patch adds stemming and fuzzy on search with index, conditioned with QueryFuzzy and QuerryStemming sysprefs. Also changes world list search (wrld) weight to r6 in order to set fuzzy search to r8 and stemming search to r9 (like search without index). Test plan : - Go to searching preferences (admin/preferences.pl?tab=searching) - Set QueryAutoTruncate to "only if * is added" - Set QueryFuzzy and QuerryStemming to "Don't try" - Set QueryWeightFields to "Enable" - Go to advanced search page - Select an indexe (ie Title) and perform a search on a short word => Look at zebrarv log and see that query does not contain right truncation : @attr 5=1 - Set QueryFuzzy to "Try" - Perform same search => Look at zebrarv log and see that query contains fuzzy : @attr 5=103 - Set QueryFuzzy to "Don't try" and QuerryStemming to "Try" - Perform same search => Look at zebrarv log and see that query contains rigth truncation on stemmed word : @attr 5=1 Signed-off-by: koha.aixmarseille Signed-off-by: Marcel de Rooy This patch makes Fuzzy and Stemming influence search results on weighted queries when using an index. Side-effect is however that the results for a search like index=term* (add truncation manually too) could be LOWER than the the number of hits for index=term. Further comments on Bugzilla. Signed-off-by: Jared Camins-Esakov --- C4/Search.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index d4ce9fb008..8261e0a30b 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -890,8 +890,11 @@ sub _build_weighted_query { $weighted_query .= " $index,ext,r1=\"$operand\""; # exact index #$weighted_query .= " or (title-sort-az=0 or $index,startswithnt,st-word,r3=$operand #)"; $weighted_query .= " or $index,phr,r3=\"$operand\""; # phrase index - $weighted_query .= - " or $index,rt,wrdl,r3=\"$operand\""; # word list index + $weighted_query .= " or $index,wrdl,r6=\"$operand\""; # word list index + $weighted_query .= " or $index,wrdl,fuzzy,r8=\"$operand\"" + if $fuzzy_enabled; # add fuzzy, word list + $weighted_query .= " or $index,wrdl,rt,r9=\"$stemmed_operand\"" + if ( $stemming and $stemmed_operand ); # add stemming, right truncation } $weighted_query .= "))"; # close rank specification -- 2.39.5