[rt-users] advanced search - customized like with wildcard

Kevin Falcone falcone at bestpractical.com
Tue Mar 23 10:06:36 EDT 2010


On Wed, Mar 17, 2010 at 09:00:16AM +0100, Joop wrote:
>    Payam Poursaied wrote:
> 
> 
> 
>      Hi all
> 
>      I'm looking for a way to search and find those tickets which their subject starts with
>      `FAX'.
> 
>      When I use "subject matches `fax'" in advanced search, the search query is something like
> 
>      ....
> 
>      main.Subject LIKE '%FAX%'
> 
>      ...
> 
> 
> 
>      But I'm looking for a way to have a query with higher performance like
> 
> 
> 
>      ....
> 
>      main.Subject LIKE 'FAX%'
> 
>      ...
> 
> 
> 
>      Is there any way to make this query?

I wonder if the better way is to expose SearchBuilder's STARTSWITH
operator in the query builder (although there may already be too many
options in the query builder).

-kevin

>    Yes, there is. I did the same thing because it kills performance each and everytime someone
>    searches for something. Only thing is you need to make your users aware of the fact that
>    including % is now needed if they don't know the exact search term.
>    I think you'll find the pre/post pending of % in SearchBuilder but I'm not completely sure so
>    let me check.....
>    Yes, its in SearchBuilder.pm the following is part of a patch that I applied to our
>    installation. Its here for reference only. Don't think you can paste it to a file and apply
>    it.
>    ---
>    --- SearchBuilder.pm.orig    Fri Jul 29 16:49:52 2005
>    +++ SearchBuilder.pm    Mon Aug 22 13:40:38 2005
>    @@ -688,9 +688,15 @@
> 
>         if ( $args{'FIELD'} ) {
> 
>    -        #If it's a like, we supply the %s around the search term
>    +        #If it's a like, we supply the %s around the search term only if its not Oracle
>    +        #because for Oracle we'll use where contains(content,'text')>1
>             if ( $args{'OPERATOR'} =~ /LIKE/i ) {
>    -            $args{'VALUE'} = "%" . $args{'VALUE'} . "%";
>    +            if ( $RT::DatabaseType == 'Oracle') {
>    +                 $args{'VALUE'} = $args{'VALUE'}
>    +            }
>    +            else {
>    +                $args{'VALUE'} = "%" . $args{'VALUE'} . "%";
>    +            }
>             }
>             elsif ( $args{'OPERATOR'} =~ /STARTSWITH/i ) {
>                 $args{'VALUE'}    = $args{'VALUE'} . "%";
>    @@ -864,6 +870,20 @@
>         }
> 
>    Regards,
> 
>    Joop

> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 2010 RT Training Sessions!
> San Francisco, CA, USA - Feb 22 & 23
> Dublin, Ireland - Mar 15 & 16
> Boston, MA, USA - April 5 & 6
> Washington DC, USA - Oct 25 & 26
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100323/8185007f/attachment.sig>


More information about the rt-users mailing list