lude results from an URL

KMandalia
Posts: 301
Joined: Fri Jul 09, 2004 3:50 pm

lude results from an URL

Post by KMandalia »

What should I type in the search box,if I want to exclude all results from a particular website?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

lude results from an URL

Post by mark »

The search script doesn't do that as is. One way you could do it would be to change it slightly to repurpose the uq variable. Change
and Url matches $$suq
to
and Url not matches $$suq
Then provide an extra box on the search form to enter urls to exclude such as http://www.someplace.com%
KMandalia
Posts: 301
Joined: Fri Jul 09, 2004 3:50 pm

lude results from an URL

Post by KMandalia »

what I meant was, is there any REX expression or way that users can type in the search box to exclude that url, like 'search term1 term2.. somerex someurl.ext'
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

lude results from an URL

Post by mark »

The search script doesn't do that as is. If you added Url to the search index, by modifying dowalk and search scripts, a user could say
term1 term2 -somesite
to exclude any records at or mentioning somesite. Or you could invent a new syntax to exclude by just url. Modify fpar to extract the new syntax and turn it into a value for $uq.
KMandalia
Posts: 301
Joined: Fri Jul 09, 2004 3:50 pm

lude results from an URL

Post by KMandalia »

Thanks.

I have decided to force users to enter their URL like www.somesite.com.

Now I just have to stick http:// in front of whatever is in the text box. I will do this in fpar and assign it to $uq. Then I just have to change

and Url matches $$uq

to

and Url not maches $$uq

Am I right all the way?

BTW, what is the value of $uq, I don't see it get assigned any value in the search script.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

lude results from an URL

Post by mark »

Sounds mostly ok. Might be a little hard to extract from query without some kind of tag in front. Maybe something like "nosite:www.somesite.com". Then you can key off the "nosite:".

$uq is not used by default. It's in there for use in situations like this. The code for handling it's all in there. You just have to decide how you want to set it.
KMandalia
Posts: 301
Joined: Fri Jul 09, 2004 3:50 pm

lude results from an URL

Post by KMandalia »

I am using a separate text box for entering urls. It is named excludeurl.

I then do the following in the search function:

<IF $excludeurl neq "">
<sum "%s" "http://" $excludeurl>
<$uq=$ret>
<$excludeurl=>
</IF>

and then

Url not maches $$uq


Doesn't work, what am I forgetting?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

lude results from an URL

Post by mark »

You need to append % to the end of the uq as well
<sum "%s" "http://" $excludeurl "%">

Also try viewing the source of the results page to see if there are warning or errors in html comments.
KMandalia
Posts: 301
Joined: Fri Jul 09, 2004 3:50 pm

lude results from an URL

Post by KMandalia »

Yup, it works now. Thank you.

Continuing along the line, could you tell me how can I tweak it so that,I can tell users that in the exclude url box if you put something like keep:www.somesite.com then instead of excluding somesite only that site will be searched.

1) How do I separate the value keep: and www.somesite.com

2) I then just need to put if/else around the sql that has Url not matches $$uq, right?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

lude results from an URL

Post by mark »

<rex ">>keep:\P=[^\space]+" $uq><$keep=$ret>
<sandr ">>keep:\P=[^\space]+" "" $uq><$uq=$ret>

You could replicate the sql, one for matches and one for not matches and choose with an if as you suggest. Or you can make it generic by creating a new query variable such as "$kq" for example. Go through the script finding where uq is processed. Do the same for kq. Then in the sql have
...
and Url matches $kq
and Url not matches $uq
...
sql will automatically ignore those clauses if the query variable is unset.
Post Reply