[ic] Prevent search from matching on html

Josh Lavin josh at myprivacy.ca
Mon Oct 30 14:54:39 EST 2006

On Oct 27, 2006, at 2:10 PM, Kevin Walsh wrote:

> Josh Lavin <josh at myprivacy.ca> wrote:
>> On Oct 26, 2006, at 5:29 PM, Kevin Walsh wrote:
>>> You are always returning a true value.  A SearchOp's coderef needs
>>> to return true if a match is found or false if no match is found.
>>> Try something like this instead:
>>>     CodeDef not_tags SearchOp
>>>     CodeDef not_tags Routine <<EOR
>>>     sub {
>>>         my ($self, $i, $pat) = @_;
>>>         $pat = qr/$pat/i;
>>>         return sub {
>>>             my $string = shift;
>>>             $string =~ s:<[/\w].+?>::gi;
>>>             return $string =~ $pat;
>>>         };
>>>     }
>>>     EOR
>> Thanks, Kevin. That did the trick, but only after I made a change to
>> Search.pm, which you mentioned here:
>> http://www.icdevgroup.org/pipermail/interchange-users/2006-July/ 
>> 045747.html
>> I was getting the same "Can't use an undefined value as an ARRAY
>> reference" error.
>> After making the change, I then started getting random bareword
>> errors. When searching for 'berkey' (a real product), sometimes it
>> would get the result, and other times this:
>> Limit subroutine creation: Bad code: Bareword found where operator
>> expected at (eval 1224) line 8, near "] aqberkey" syntax error at
>> (eval 1224) line 8, near "] aqberkey "
>> This is mentioned here:
>> http://www.icdevgroup.org/pipermail/interchange-users/2004-June/ 
>> 039504.html
> Ok.  Perhaps I'll take a look into that at some point, but not right
> now.  I assume you have a reasonably up to date Perl installation.
> I use the 5.8.8 version that comes with Gentoo GNU/Linux.  There's
> probably not a lot of point looking into it if you have Perl 5.6.

I have Perl 5.8.7.

> If you're using RPC mode then perhaps you should drop out of that,
> back to high/low traffic mode, and see if that helps.

Changing from RPC to High solved the problem. However, I removed the  
mv_column_op for the Text::Query module (aq), and now it works fine,  
even in RPC mode. :-)

>> Another thing, perhaps unrelated, is how to search multiple fields
>> with a custom SearchOp and get it to work on all? E.g.:
>> sf=description
>> vs.
>> sf=description,comment
> I think that should "just work".  Have you tried it and verified that
> it fails?  What happens when you try?  What happens with "sf=*"?

Using more than one search field, or sf=*, or sf=:* with a custom  
SearchOp causes the search to fail. Maybe because it is now an array?

Josh Lavin
Kingdom Design   http://www.kingdomdesign.com/

More information about the interchange-users mailing list