diff --git a/lib/RT/Search/Simple.pm b/lib/RT/Search/Simple.pm index 477a2dcf9a..dddb5a6b2c 100644 --- a/lib/RT/Search/Simple.pm +++ b/lib/RT/Search/Simple.pm @@ -172,7 +172,12 @@ sub QueryToSQL { next unless @{$limits{$subclause}}; my $op = $AND{lc $subclause} ? "AND" : "OR"; - push @clauses, "( ".join(" $op ", @{$limits{$subclause}})." )"; + if ( @{$limits{$subclause}} == 1 && $limits{$subclause}[0] =~ /^\(.+\)$/) { + push @clauses, @{$limits{$subclause}}; + } + else { + push @clauses, "( ".join(" $op ", @{$limits{$subclause}})." )"; + } } return join " AND ", @clauses; @@ -280,9 +285,9 @@ sub GuessType { sub HandleDefault { my $fts = RT->Config->Get('FullTextSearch'); if ($fts->{Enable} and $fts->{Indexed}) { - return default => "(Subject LIKE '$_[1]' OR Content LIKE '$_[1]')"; + return default => "( Subject LIKE '$_[1]' OR Description LIKE '$_[1]' OR Content LIKE '$_[1]' )"; } else { - return default => "Subject LIKE '$_[1]'"; + return default => "( Subject LIKE '$_[1]' OR Description LIKE '$_[1]' )"; } } sub HandleSubject { return subject => "Subject LIKE '$_[1]'"; } diff --git a/share/html/Search/Simple.html b/share/html/Search/Simple.html index f7853753b9..3909d1a6f2 100644 --- a/share/html/Search/Simple.html +++ b/share/html/Search/Simple.html @@ -65,9 +65,9 @@ % my @strong = qw( ); -
<&|/l_unsafe, @strong &>Search for tickets by entering [_1]id[_2] numbers, subject words [_1]"in quotes"[_2], [_1]queues[_2] by name, Owners by [_1]username[_2], Requestors by [_1]email address[_2], and ticket [_1]statuses[_2]. Searching for [_1]@domainname.com[_2] will return tickets with requestors from that domain.&>
+<&|/l_unsafe, @strong &>Search for tickets by entering [_1]id[_2] numbers, subject/description words [_1]"in quotes"[_2], [_1]queues[_2] by name, Owners by [_1]username[_2], Requestors by [_1]email address[_2], and ticket [_1]statuses[_2]. Searching for [_1]@domainname.com[_2] will return tickets with requestors from that domain.&>
-<&|/l&>Any word not recognized by RT is searched for in ticket subjects.&>
+<&|/l&>Any word not recognized by RT is searched for in ticket subjects and descriptions.&>
% my $config = RT->Config->Get('FullTextSearch') || {}; % my $fulltext_keyword = 'fulltext:'; diff --git a/t/web/simple_search.t b/t/web/simple_search.t index bb023b5801..088176a957 100644 --- a/t/web/simple_search.t +++ b/t/web/simple_search.t @@ -25,36 +25,36 @@ my $root = RT::Test->load_or_create_user( Name => 'root' ); TicketsObj => $tickets, Argument => '', ); - is $parser->QueryToSQL("foo"), "( (Subject LIKE 'foo' OR Description LIKE 'foo') ) AND ( Status = '__Active__' )", "correct parsing"; - is $parser->QueryToSQL("1 foo"), "( (Subject LIKE 'foo' OR Description LIKE 'foo') AND (Subject LIKE '1' OR Description LIKE '1') ) AND ( Status = '__Active__' )", "correct parsing"; + is $parser->QueryToSQL("foo"), "( Subject LIKE 'foo' OR Description LIKE 'foo' ) AND ( Status = '__Active__' )", "correct parsing"; + is $parser->QueryToSQL("1 foo"), "( ( Subject LIKE 'foo' OR Description LIKE 'foo' ) AND ( Subject LIKE '1' OR Description LIKE '1' ) ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("1"), "( Id = 1 )", "correct parsing"; is $parser->QueryToSQL("#1"), "( Id = 1 )", "correct parsing"; - is $parser->QueryToSQL("'1'"), "( (Subject LIKE '1' OR Description LIKE '1') ) AND ( Status = '__Active__' )", "correct parsing"; + is $parser->QueryToSQL("'1'"), "( Subject LIKE '1' OR Description LIKE '1' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("foo bar"), - "( (Subject LIKE 'foo' OR Description LIKE 'foo') AND (Subject LIKE 'bar' OR Description LIKE 'bar') ) AND ( Status = '__Active__' )", + "( ( Subject LIKE 'foo' OR Description LIKE 'foo' ) AND ( Subject LIKE 'bar' OR Description LIKE 'bar' ) ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("'foo bar'"), - "( (Subject LIKE 'foo bar' OR Description LIKE 'foo bar') ) AND ( Status = '__Active__' )", + "( Subject LIKE 'foo bar' OR Description LIKE 'foo bar' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("'foo \\' bar'"), - "( (Subject LIKE 'foo \\' bar' OR Description LIKE 'foo \\' bar') ) AND ( Status = '__Active__' )", + "( Subject LIKE 'foo \\' bar' OR Description LIKE 'foo \\' bar' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL('"foo \' bar"'), - "( (Subject LIKE 'foo \\' bar' OR Description LIKE 'foo \\' bar') ) AND ( Status = '__Active__' )", + "( Subject LIKE 'foo \\' bar' OR Description LIKE 'foo \\' bar' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL('"\f\o\o"'), - "( (Subject LIKE '\\\\f\\\\o\\\\o' OR Description LIKE '\\\\f\\\\o\\\\o') ) AND ( Status = '__Active__' )", + "( Subject LIKE '\\\\f\\\\o\\\\o' OR Description LIKE '\\\\f\\\\o\\\\o' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("General"), "( Queue = 'General' ) AND ( Status = '__Active__' )", "correct parsing"; - is $parser->QueryToSQL("'Two Words'"), "( (Subject LIKE 'Two Words' OR Description LIKE 'Two Words') ) AND ( Status = '__Active__' )", "correct parsing"; + is $parser->QueryToSQL("'Two Words'"), "( Subject LIKE 'Two Words' OR Description LIKE 'Two Words' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("queue:'Two Words'"), "( Queue = 'Two Words' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("subject:'Two Words'"), "( Status = '__Active__' ) AND ( Subject LIKE 'Two Words' )", "correct parsing"; is $parser->QueryToSQL("me"), "( Owner.id = '__CurrentUser__' ) AND ( Status = '__Active__' )", "correct parsing"; - is $parser->QueryToSQL("'me'"), "( (Subject LIKE 'me' OR Description LIKE 'me') ) AND ( Status = '__Active__' )", "correct parsing"; + is $parser->QueryToSQL("'me'"), "( Subject LIKE 'me' OR Description LIKE 'me' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("owner:me"), "( Owner.id = '__CurrentUser__' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL("owner:'me'"), "( Owner = 'me' ) AND ( Status = '__Active__' )", "correct parsing"; is $parser->QueryToSQL('owner:root@localhost'), "( Owner.EmailAddress = 'root\@localhost' ) AND ( Status = '__Active__' )", "Email address as owner";