[rt-users] RTFM Search assistance needed

AJ rt at musefoundry.com
Wed Jan 14 11:59:15 EST 2004


I sent this question to the devel list but got no response so I am sending
it here with hopes that someone can shed some light on this for me. Here is
a more concise version..
 
I need to simplify the RTFM search.  Insert the search terms in one fields
and all the custom fields for all the classes are searched.
I created a quicksearch page that posts to another page with this init code:
 
my @SEARCH=split(/\s/,$ARGS{'SearchAll'}); #the original list of terms from
the post args
my @EXAMPLE=qw(fred wilma); #hardcoded debugging list of terms
my $articles = RT::FM::ArticleCollection->new( $session{'CurrentUser'});
#doing the search as root to take any permissions variables out
$articles->LimitToCustomFieldValue( OPERATOR=> 'LIKE', ENTRYAGGREGATOR =>
'OR', VALUE=>\@EXAMPLE );
 
The query it generates, no matter what the ENTRYAGGREGATOR is, can be seen
below.  A perfectly good query if only that last AND was an OR. I ran it
manually with the or and I do get a valid response.
 
SELECT count(DISTINCT main.id) FROM ( ( FM_Articles main LEFT JOIN
FM_ArticleCFValues as FM_ArticleCFValues_1  ON  ( main.id =
FM_ArticleCFValues_1.Article)) LEFT JOIN FM_ArticleCFValues as
FM_ArticleCFValues_2  ON  ( main.id = FM_ArticleCFValues_2.Article))  WHERE
((FM_ArticleCFValues_1.Content LIKE '%fred%')) AND
((FM_ArticleCFValues_2.Content LIKE '%wilma%'))
 
I need to know what I am doing wrong. I dug into the DBIx module code and it
looks like the left joins and whereclauses may be hard coded to 'AND' in
some instances and there is probably a very valid SQL reason for this.   I
am thinking there is another way to do this with Limit but am unsure.  
 
Can anyone help? In return, I have attached a CreateTickets_Local.pm action
that will take any custom fields in the parent ticket and add them to the
child tickets. Therefore, if there is important info in the parent that is
in the form of a custom field, the field does not need to be global and the
child will have the info and there is no need to know what the custom field
id is.  
 
Thank you..
AJ
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20040114/8a27bf22/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CreateTickets_Local.pm
Type: application/octet-stream
Size: 17449 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20040114/8a27bf22/attachment.obj>


More information about the rt-users mailing list