From 233a40f1d194060da2f47afbfec1dda4120fff34 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 9 Jun 2008 11:33:04 -0500 Subject: [PATCH] bug 2098: do not apply stemming if search term has digits If a search 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, C4::Search::_build_stemmend_operand would reduce "014100018X" to "x ", which for a MARC21 database would bring up irrelevant results (e.g., "23 x 29 cm." from the 300$c). With this patch, supplying a search term that contains one or more digits followed by "X" will no longer retrieve irrelevant results. This applies to catalogs using Zebra and query stemming. Signed-off-by: Joshua Ferraro --- C4/Search.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/Search.pm b/C4/Search.pm index bfb4b10dfa..7442847299 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -747,6 +747,13 @@ sub _build_stemmed_operand { my ($operand) = @_; my $stemmed_operand; + # 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 + # "014100018X" to "x ", which for a MARC21 database would bring up irrelevant + # results (e.g., "23 x 29 cm." from the 300$c). Bug 2098. + return $operand if $operand =~ /\d/; + # FIXME: the locale should be set based on the user's language and/or search choice my $stemmer = Lingua::Stem->new( -locale => 'EN-US' ); -- 2.39.5