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
https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.