[Rt-commit] rt branch, 4.2/simple-search, created. rt-4.2.3-88-g6b44a58
Alex Vandiver
alexmv at bestpractical.com
Fri Apr 18 17:25:41 EDT 2014
The branch, 4.2/simple-search has been created
at 6b44a58c09f10d1e9b5b19b87917d87a9174a25f (commit)
- Log -----------------------------------------------------------------
commit 0da97b8c747464a8c63bcf95628e50c2c676d7f0
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 17:20:10 2014 -0400
Searches for numbers as well as words should treat numbers as strings
This prevents false-negatives when "ip version 6" is typed into the
search box, for instance. It still allows "4 5 6" to find multiple
tickets by number.
Fixes I#22470.
diff --git a/lib/RT/Search/Simple.pm b/lib/RT/Search/Simple.pm
index ba1bfdc..0d88fa1 100644
--- a/lib/RT/Search/Simple.pm
+++ b/lib/RT/Search/Simple.pm
@@ -173,6 +173,16 @@ sub Finalize {
my $self = shift;
my ($limits) = @_;
+ # Assume that numbers were actually "default"s if we have other limits
+ if ($limits->{id} and keys %{$limits} > 1) {
+ my $values = delete $limits->{id};
+ for my $value (@{$values}) {
+ $value =~ /(\d+)/ or next;
+ my ($key, @tsql) = $self->HandleDefault($1);
+ push @{$limits->{$key}}, @tsql;
+ }
+ }
+
# Apply default "active status" limit if we don't have any status
# limits ourselves, and we're not limited by id
if (not $limits->{status} and not $limits->{id}
commit 6b44a58c09f10d1e9b5b19b87917d87a9174a25f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 17:23:43 2014 -0400
Search subject as well as content if FTS is enabled
If indexed full-text searching is enabled, the simple search will search
for each value in both Subject and Content.
diff --git a/lib/RT/Search/Simple.pm b/lib/RT/Search/Simple.pm
index 0d88fa1..ae9ee53 100644
--- a/lib/RT/Search/Simple.pm
+++ b/lib/RT/Search/Simple.pm
@@ -71,6 +71,7 @@ use Regexp::Common qw/delimited/;
# Only a subset of limit types AND themselves together. "queue:foo
# queue:bar" is an OR, but "subject:foo subject:bar" is an AND
our %AND = (
+ default => 1,
content => 1,
subject => 1,
);
@@ -204,7 +205,7 @@ sub Finalize {
}
our @GUESS = (
- [ 10 => sub { return "subject" if $_[1] } ],
+ [ 10 => sub { return "default" if $_[1] } ],
[ 20 => sub { return "id" if /^#?\d+$/ } ],
[ 30 => sub { return "requestor" if /\w+@\w+/} ],
[ 35 => sub { return "domain" if /^@\w+/} ],
@@ -241,7 +242,14 @@ sub GuessType {
# $_[2] is a boolean of "was quoted by the user?"
# ensure this is false before you do smart matching like $_[1] eq "me"
# $_[3] is escaped subkey, if any (see HandleCf)
-sub HandleDefault { return subject => "Subject LIKE '$_[1]'"; }
+sub HandleDefault {
+ my $fts = RT->Config->Get('FullTextSearch');
+ if ($fts->{Enable} and $fts->{Indexed}) {
+ return default => "(Subject LIKE '$_[1]' OR Content LIKE '$_[1]')";
+ } else {
+ return default => "Subject LIKE '$_[1]'";
+ }
+}
sub HandleSubject { return subject => "Subject LIKE '$_[1]'"; }
sub HandleFulltext { return content => "Content LIKE '$_[1]'"; }
sub HandleContent { return content => "Content LIKE '$_[1]'"; }
-----------------------------------------------------------------------
More information about the rt-commit
mailing list