Bug 46221
Relevance + AND by default git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@427 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
0379ec2963
commit
3e58bcd54f
|
@ -165,22 +165,29 @@ sub sql_string_concat {
|
||||||
sub sql_fulltext_search {
|
sub sql_fulltext_search {
|
||||||
my ($self, $column, $text) = @_;
|
my ($self, $column, $text) = @_;
|
||||||
|
|
||||||
# Add the boolean mode modifier if the search string contains
|
# quote un-quoted compound words
|
||||||
# boolean operators at the start or end of a word.
|
my @words = quotewords('[\s()]+', 'delimiters', $text);
|
||||||
my $mode = '';
|
if ($text =~ /(?:^|\W)[+\-<>~"()]/ || $text =~ /[()"*](?:$|\W)/)
|
||||||
if ($text =~ /(?:^|\W)[+\-<>~"()]/ || $text =~ /[()"*](?:$|\W)/) {
|
{
|
||||||
$mode = 'IN BOOLEAN MODE';
|
# already a boolean mode search
|
||||||
|
foreach my $word (@words)
|
||||||
# quote un-quoted compound words
|
{
|
||||||
my @words = quotewords('[\s()]+', 'delimiters', $text);
|
|
||||||
foreach my $word (@words) {
|
|
||||||
# match words that have non-word chars in the middle of them
|
# match words that have non-word chars in the middle of them
|
||||||
if ($word =~ /\w\W+\w/ && $word !~ m/"/) {
|
if ($word =~ /\w\W+\w/ && $word !~ /\"/)
|
||||||
|
{
|
||||||
$word = '"' . $word . '"';
|
$word = '"' . $word . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$text = join('', @words);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# make search a boolean mode search
|
||||||
|
for (@words)
|
||||||
|
{
|
||||||
|
$_ = "+$_*" if /\w$/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$text = join '', @words;
|
||||||
|
|
||||||
# quote the text for use in the MATCH AGAINST expression
|
# quote the text for use in the MATCH AGAINST expression
|
||||||
$text = $self->quote($text);
|
$text = $self->quote($text);
|
||||||
|
@ -188,7 +195,7 @@ sub sql_fulltext_search {
|
||||||
# untaint the text, since it's safe to use now that we've quoted it
|
# untaint the text, since it's safe to use now that we've quoted it
|
||||||
trick_taint($text);
|
trick_taint($text);
|
||||||
|
|
||||||
return "MATCH($column) AGAINST($text $mode)";
|
return ("MATCH($column) AGAINST($text IN BOOLEAN MODE)", "MATCH($column) AGAINST($text)");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sql_istring {
|
sub sql_istring {
|
||||||
|
|
|
@ -676,6 +676,7 @@ sub disable_utf8 {
|
||||||
sub stem_text
|
sub stem_text
|
||||||
{
|
{
|
||||||
my ($text, $allow_verbatim) = @_;
|
my ($text, $allow_verbatim) = @_;
|
||||||
|
Encode::_utf8_on($text) if Bugzilla->params->{utf8};
|
||||||
$text = [ split /(?<=\w)(?=\W)|(?<=\W)(?=\w)/, $text ];
|
$text = [ split /(?<=\w)(?=\W)|(?<=\W)(?=\w)/, $text ];
|
||||||
my $q = 0;
|
my $q = 0;
|
||||||
for (@$text)
|
for (@$text)
|
||||||
|
@ -684,10 +685,17 @@ sub stem_text
|
||||||
{
|
{
|
||||||
$_ = Lingua::Stem::RuUTF8::stem_word($_) unless $q;
|
$_ = Lingua::Stem::RuUTF8::stem_word($_) unless $q;
|
||||||
}
|
}
|
||||||
elsif ($allow_verbatim)
|
else
|
||||||
{
|
{
|
||||||
# If $allow_verbatim is TRUE then text in "double quotes" doesn't stem
|
if ($allow_verbatim)
|
||||||
$q = ($q + tr/\"/\"/) % 2;
|
{
|
||||||
|
# If $allow_verbatim is TRUE then text in "double quotes" doesn't stem
|
||||||
|
$q = ($q + tr/\"/\"/) % 2;
|
||||||
|
}
|
||||||
|
if (!/\s$/so)
|
||||||
|
{
|
||||||
|
$_ .= ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return join '', @$text;
|
return join '', @$text;
|
||||||
|
|
Loading…
Reference in New Issue