Is there a PHP library (or maybe a snippet) which would cover the following search functionality?
- “an exact phrase”
- all these words
- this OR that
- this but -not -these
I have an array, which arrives from MySQL database, and would like to filter the items based on a query, which has one or more rules I’ve specified above. For example, the query may look like this: word1 "word2 word3" -word4. This query would return all items containing word1 and word2 word3 (phrase) in any order, but not word4.
You can do this with plain MySQL.
The functions have everything you need.
http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
Boolean :
http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
Example for a perfect match you use the
LIKEkeyword and%.