[ic] Prevent search from matching on html
Kevin Walsh
kevin at cursor.biz
Fri Oct 27 15:10:37 EDT 2006
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.
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.
Feel free to play around in lib/Vend/Search.pm, if you have some time.
Let us know the results of any investigation you carry out - especially
if you find/fix the cause. :-)
>
> 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=*"?
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin at cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/
More information about the interchange-users
mailing list