I am doing a search in two text fields called Subject
and Text
for a specific keyword. To do this I use the LIKE
statement. I have encount
// escape $keyword for mysql
$keyword = strtolower('Keyword');
// now build the query
$query = <<
Returns number of occurrences in each field and sorts by that.
The 'keyword'
needs to be lower cased for this to work. I don't think it's really fast, performance wise as it needs to lower-case fields and there's no case-insensitive search in MySQL afaik.
You could index each news
item (subject
and text
) by words and store in another table with news_id
and occurrence count and then match against that.