How to search singular/plurals in php mysql -


when enter word (ex: freshers) want fresher , freshers records both getting freshers records. code this:

$search='freshers'; $qry=mysql_query("select count(*) jobs job_title '%$search%' or match(job_title) against('$search' in boolean mode)"); 

when search word freshers m getting count 1200. when search word fresher again getting count 2000.

how same count when enter either freshers or fresher.

you cannot precisely same matching-record count mysql technology search term that's either singular or plural.

mysql doesn't have smarts know freshers plural of fresher or children plural of child. if want mysql you'll have start search singular form of word want plural.

neither mysql know mice plural of mouse.

if need automated plural/singular functionality may want investigate lucene or other natural language search tech. name of capability seek "stemming."

but can use fulltext search terms trailing asterisks. example, 'fresher*' matches fresher, freshers, , fresherola. extend search singular plural. not work other way around. it

select count(*)    jobs  match(job_title) against('fresher*' in boolean mode) 

there other modifying characters boolean mode search terms. mentioned here:

http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

pro tip: column '%searchterm%' slowest way mysql offers search column. guaranteed scan whole table.

pro tip: fulltext search inherently bit fuzzy. expecting crisp record counts path confusion.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -