From bf7f3d08d66cfdb2496296cd0565516adafeabd5 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 --- C4/Search.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 50f7d2b..06befdf 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -872,8 +872,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 -- 1.7.10.4