searching multiple directories

Post Reply
User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

searching multiple directories

Post by Thunderstone »



In order to keep our database sizes down, I'm trying to use one
database per site. We have both a public and a private area and want
to have users search just product services or just tech support. So
far this is going well, but I can't seem to specify multiple
directories.

Here's what I'm trying to do:

<IF $usertype eq "private">
<$findpath = "/my.site.com/">
<ELSE>
<$findpath = "/my.site.com/public/" "/my.site.com/public2/">
</IF>
<SQL SKIP=$oldskip MAX=$maxLinks
"select $$rank Rank, id, Url, Title, Body, length(Body) Size
from html
where Title\Meta\Body likep $query and Url like $findpath">
<matchline>
</SQL>


Everything works fine if I only use one value for $findpath, but when
I try using multiple paths, I get "No documents found". What I
believe is happening is that it trys to match the url to BOTH paths
(which should never happen since they are entirely different according
to REX) instead of EITHER. I've also tried "Url matches $findpath"
but I think that does the same thing ($findpath =
"my.site.com/public/%", etc).

Is there a better way of getting my results that putting each path
into a separate variable and using "Url like $path1 OR Url like
$path2..."?

Is it passible for REX to do alternation as in the perl code:
$Url =~ m/my.site.com\/(public\/)|(public2\/)/;

I didn't see anything of that type in
http://www.thunderstone.com/vortexman/node77.html but I may have
overlooked something.


Thanks,
Tim


User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

searching multiple directories

Post by Thunderstone »



You could have put both paths into a single query with @0, but a better
approach would be to use matches and change the query based on usertype:

<IF $usertype eq "private">
<$sql="select $$$$rank Rank, id, Url, Title, Body, length(Body) Size
from html
where Title\Meta\Body likep $$query">
<ELSE>
<$findpath = "/my.site.com/public/" "/my.site.com/public2/">
<$sql="select $$$$rank Rank, id, Url, Title, Body, length(Body) Size
from html
where Title\Meta\Body likep $$query
and (Url matches 'my.site.com/public/%' or
Url matches 'my.site.com/public2/%')">
</IF>
<SQL SKIP=$oldskip MAX=$maxLinks $sql>
...



Post Reply