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 <jmf@liblime.com>
This commit is contained in:
Galen Charlton 2008-06-09 11:33:04 -05:00 committed by Joshua Ferraro
parent 5b7d362472
commit 233a40f1d1
1 changed files with 7 additions and 0 deletions

View File

@ -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' );