[rt-users] simple search not finding words in subjects?

Matt Zagrabelny mzagrabe at d.umn.edu
Wed Nov 30 10:56:25 EST 2016


On Wed, Nov 30, 2016 at 9:46 AM, Alex Hall <ahall at autodist.com> wrote:
> Hi all,
> My boss said he couldn't find a ticket that he thought he should be able to
> find. He was searching a customer name, let's say Custname. I thought at
> first the problem was that the ticket was resolved, but I was wrong.
>
> The problem appears to be that simple search is looking for "content like
> "searchTerm"". When I changed it to "subject like "searchTerm"", the ticket
> in question came right up.
>
> I guess I need to set simple search to look for "content like "searchTerm"
> OR subject like "searchTerm"". But I see no way to customize the simple
> search query in the configuration options. Is this possible?

Yes.

 If so, what's
> the recommended way?

Use a callback. In fact, use this one:

Search/Simple.html/ModifyQuery

I don't see us using this callback in our current RT installation, but
here is the contents of our callback for our legacy (3.8) install. It
doesn't do what you are asking about, but it should give you a feel
for the callback.

cat /usr/local/share/request-tracker3.8/plugins/RT-Site-UMN-Duluth/html/Callbacks/RT-Site-UMN-Duluth/Search/Simple.html/ModifyQuery
<%INIT>
my %statuses;
if (RT->Config->Get("ActiveStatus")) {
  %statuses = map { $_ => 1 } RT->Config->Get("ActiveStatus"); # Put
active statuses into our hash
}
if (RT->Config->Get("InactiveStatus")) {
  %statuses = (map({ $_ => 1 } RT->Config->Get("InactiveStatus")),
%statuses); # Put inactive statuses into our hash
}

my $all_statuses = join "|", keys %statuses;

delete $statuses{rejected};
delete $statuses{deleted};
my $statuses_we_care_about = join " ", keys %statuses;
# if 'query' does not have a status word in the query or is not
strictly a number
# then prepend some statuses to the query
if ($$query !~ /\b(?:$all_statuses)\b|^\s*\d+\s*$/i ) {
   $$query = "$statuses_we_care_about $$query";
}
</%INIT>
<%ARGS>
$query => undef
</%ARGS>

-m



More information about the rt-users mailing list