Bugzilla – Attachment 71285 Details for
Bug 20151
Search is broken when stemming has no language
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20151: always use current language for stemming
Bug-20151-always-use-current-language-for-stemming.patch (text/plain), 4.67 KB, created by
Fridolin Somers
on 2018-02-07 15:30:30 UTC
(
hide
)
Description:
Bug 20151: always use current language for stemming
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2018-02-07 15:30:30 UTC
Size:
4.67 KB
patch
obsolete
>From c4f21340be3f93c6b0cfe8c521d1371d346530d4 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 7 Feb 2018 15:06:56 +0100 >Subject: [PATCH] Bug 20151: always use current language for stemming > >When stemming is enable in catalog searching, C4::Search::_build_stemmed_operand will transform operand into stemmed operand using stemmer Lingua::Stem::Snowball with a specified language. >This stemmer returns undef is no language is defined. > >In classic catalog search, current language is used. >But in other pages acqui/neworderbiblio.pl and cataloguing/addbooks.pl no language is defined so operand is empty. >Any search returns entire catalog. > >This patch corrects by returning operand without change if no langage is defined in C4::Search::_build_stemmed_operand. And uses current langage in pages acqui/neworderbiblio.pl and cataloguing/addbooks.pl. > >Test plan : >1) Enable system preferences QueryStemming and QueryWeightFields >2) Disable system preferences QueryAutoTruncate, QueryFuzzy and UseQueryParser >3) Perform an search in catalog (without index) that uses the stemming, for example "historical" will search "histor*" >4) Go to "Cataloging" >5) Perform a search on same word in "Cataloging search" >6) Without patch you have entire catalog, with patch you have correct number of results >7) Go to aquisition on a basket and click "Add to basket" >8) Perform search in "From an existing record" >9) Without patch you have entire catalog, with patch you have correct number of results >--- > C4/Search.pm | 3 +++ > acqui/neworderbiblio.pl | 5 ++++- > cataloguing/addbooks.pl | 5 ++++- > 3 files changed, 11 insertions(+), 2 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index c11a61e..d3ce4fd 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -963,6 +963,9 @@ sub _build_stemmed_operand { > require Lingua::Stem::Snowball ; > my $stemmed_operand=q{}; > >+ # Stemmer needs language >+ return $operand unless $lang; >+ > # If operand contains a digit, it is almost certainly an identifier, and should > # not be stemmed. This is particularly relevant for ISBNs and ISSNs, which > # can contain the letter "X" - for example, _build_stemmend_operand would reduce >diff --git a/acqui/neworderbiblio.pl b/acqui/neworderbiblio.pl >index f083398..b48737d 100755 >--- a/acqui/neworderbiblio.pl >+++ b/acqui/neworderbiblio.pl >@@ -64,6 +64,7 @@ use C4::Auth; > use C4::Output; > use C4::Koha; > use C4::Budgets qw/ GetBudgetHierarchy /; >+use C4::Languages qw(getlanguage); > > use Koha::Acquisition::Booksellers; > use Koha::SearchEngine; >@@ -83,6 +84,7 @@ my $booksellerid = $params->{'booksellerid'}; > my $basketno = $params->{'basketno'}; > my $sub = $params->{'sub'}; > my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); >+my $lang = C4::Languages::getlanguage($input); > > # getting the template > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -106,7 +108,8 @@ my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BI > if ($QParser) { > $builtquery = $query; > } else { >- ( undef,$builtquery,undef,undef,undef,undef,undef,undef,undef,undef) = $builder->build_query_compat(undef,\@operands); >+ ( undef, $builtquery, undef, undef, undef, undef, undef, undef, undef, undef ) = >+ $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang ); > } > my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page); > >diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index ae4d7ac..c01e861 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -32,6 +32,7 @@ use C4::Biblio; > use C4::Breeding; > use C4::Output; > use C4::Koha; >+use C4::Languages qw(getlanguage); > use C4::Search; > > use Koha::BiblioFrameworks; >@@ -45,6 +46,7 @@ my $query = $input->param('q'); > my @value = $input->multi_param('value'); > my $page = $input->param('page') || 1; > my $results_per_page = 20; >+my $lang = C4::Languages::getlanguage($input); > > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -74,7 +76,8 @@ if ($query) { > if ($QParser) { > $builtquery = $query; > } else { >- ( undef,$builtquery,undef,undef,undef,undef,undef,undef,undef,undef) = $builder->build_query_compat(undef,\@operands); >+ ( undef, $builtquery, undef, undef, undef, undef, undef, undef, undef, undef ) = >+ $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang ); > } > # find results > my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20151
:
71285
|
78994
|
78997
|
80253