How can I match variations on words in MySQL, for example a search for accountancy should match accountant, accountants, accounting etc. I’m on shared hosting so can’t add any functions to MySQL such as levenshtein.
I want something similar to how Google matches ‘accounting course‘ and ‘accountancy courses‘ when searching for ‘accountant courses‘. Example.
My server language is php, if it’s only possible to implement it there and not in SQL.
The current statement is as follows.
SELECT
pjs.title,
MATCH (pjs.title) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel1,
MATCH (pjs.description) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel2,
MATCH (
pjs.benefits,
pjs.experienceRequirements,
pjs.incentives,
pjs.qualifications,
pjs.responsibilities,
pjs.skills
) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel3
FROM
pxl_jobsearch AS pjs
ORDER BY (rel1 * 5) + (rel2 * 1.5) + (rel3) DESC;
MySQL isn’t very good at full text search and you’d probably want to use other engines. My favorite one is Sphinx (http://sphinxsearch.com/) but there are others as well. Most of these support stemming out of the box.
If you have large tables and are going to use stemming the performance of MySQL will probably be very bad.
If you can’t use Sphinx, take a look at this php script http://tartarus.org/~martin/PorterStemmer/php.txt
With this you can use stemming, and the search on the stemmed words.