为情所困2017-05-16 13:14:53
Try the elasticsearch search engine, which supports word segmentation, full-text search, and can also be sorted based on similarity
迷茫2017-05-16 13:14:53
Either you have your own search department to develop it yourself, or you use some of the popular open source search engines, such as solr and elasticsearch
淡淡烟草味2017-05-16 13:14:53
Let me tell you my idea: convert Chinese characters into pinyin and then perform full-text search.
// PHP利用ICU扩展intl实现汉字转拼音
echo transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', '德克士'); //de ke shi
echo transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', '得克'); //de ke
// 假设name字段内容为"德克士",则name_fts字段内容为"de ke shi".
// MySQL全文检索字段name_fts中同时包含"得克"关键字de和ke的商店记录.
// 所以 name_fts 中包含de和ke的店铺都能显示出来.
SELECT name FROM store
WHERE MATCH(name_fts) AGAINST('+de +ke' IN BOOLEAN MODE)
ORDER BY id DESC LIMIT 5;