SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help With SQL Code For Basic Search
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

scottie35s
Starting Member

2 Posts

Posted - 02/06/2013 :  11:36:48  Show Profile  Reply with Quote
Hi, the basic search on my site is too specific.. Meaning it's too exact with word order and phrases.

For example, if I search Shoes Red it won't show results for Red Shoes.

If you search for Red Shoe Laces it won't show results for Red Laces (as the word shoe throws off this order). Below is the code that I believe the search box is using. Can anyone tell me how to "loosen" up this search so it's either more broad or so exact word order isn't necessary?

This is the current code:

case 'search':
if (intval($filter) != 0) {
$filter = JString::strtolower($filter);
$id = intval($filter);
$search .= $temp."(a.id = $id OR LOWER(a.ad_headline) LIKE '%".$this->_db->getEscaped($filter,true)."%' OR LOWER(a.ad_text) LIKE '%".$this->_db->getEscaped($filter,true)."%')";
} else {
$filter = JString::strtolower($filter);
$search .= $temp."(LOWER(a.ad_headline) LIKE '%".$this->_db->getEscaped($filter,true)."%' OR LOWER(a.ad_text) LIKE '%".$this->_db->getEscaped($filter,true)."%')";
}
break;
}
}
}
return $search;
}


Any ideas here?

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/06/2013 :  11:40:17  Show Profile  Reply with Quote
sounds like full text search to me

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

scottie35s
Starting Member

2 Posts

Posted - 02/06/2013 :  12:08:52  Show Profile  Reply with Quote
How do I fix this code though?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/06/2013 :  22:56:35  Show Profile  Reply with Quote
see
http://technet.microsoft.com/en-us/library/cc966489.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000