Jump to content

Filter inappropriate search results


phpsycho

Recommended Posts

Okay so here is my query:

$sql = "SELECT * FROM `search_links` WHERE MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords' IN BOOLEAN MODE)  
ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15";

that works perfect but I get results that have inappropriate links desc etc so I would like to filter them..

I tried:

$banned = "-sex -porn -anal"; //etc
$sql = "SELECT * FROM `search_links` WHERE MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords $banned' IN BOOLEAN MODE) 
ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15";

That works fine, but when I want to filter results with two words it won't work.. example:

$banned = "-word1 word2 -word3 word4"; //doesn't work..
$banned = "-\"word1 word2\" -\"word3 word4\""; //doesn't work either
$banned = "-(word1 word2) -(word3 word4)"; //and of course this doesn't work either..

 

soo I tried doing..

$sql = "SELECT * FROM `search_links` WHERE `title` NOT IN ('sex','porn') AND MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords' IN BOOLEAN MODE) 
ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15";

and that doesn't filter or do anything at all..

 

How can I filter results inside the query?

Thanks!

Link to comment
Share on other sites

wow this is like the strangest thing I have seen..

It just totally ignores the word sex.

I put the word sex in each the title desc and keywords and then the $banned var like this:

$banned = "-sex -Sex -SEX";

still shows the results containing the word sex.

But like I said before -porn will remove all results containing 'porn'.

:shrug:

 

I also tried just matching `title` or `description` or `keywords` and then against my keywords(search term) and -sex

still don't work.

Link to comment
Share on other sites

huh never mind lol sorry it works now. -"word1 word2"

I didn't realize what I was doing wrong.. keywords don't get echoed out but sense I am actually trying to filter out zoophilia content I searched for = "animal sex" and stuff showed up but not all had "animal sex" in the title or desc soo I thought okay if I then filter out -"animal sex" then I should only see those other results without those words in the title or desc. wrong of course lol

basically just didn't think it out well, I was searching and filtering out the same thing  ::)

Thanks for that link though, probably would have taken me a while to figure out there was a min char limit.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.