When using php to develop a website, where is the search box? When inputting, the user input method is not switched properly. There may be situations where the input is pinyin. So how to convert pinyin to Chinese characters and query the database to display the corresponding products! I originally wanted to use sphinx, but I had no choice but to install it for several days without success!
为情所困2017-06-24 09:44:17
This is word association, which cannot be achieved without a huge local vocabulary library. It is recommended to use a third-party API
伊谢尔伦2017-06-24 09:44:17
Use third-party search support elasticsearch
, xunsearch
, sphinx
and other processing
巴扎黑2017-06-24 09:44:17
In fact, you can add a pinyin field to the product, which will make the search better
三叔2017-06-24 09:44:17
This is word association, which cannot be achieved without a huge local vocabulary library. It is recommended to use a third-party API
仅有的幸福2017-06-24 09:44:17
// PHP利用ICU扩展intl实现汉字转拼音
echo transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', '小米'); //xiao mi
// MySQL全文检索字段name_fts中同时包含关键字xiao mi的商店记录.
SELECT name FROM store
WHERE MATCH(name_fts)
AGAINST('+xiao +mi' IN BOOLEAN MODE)
ORDER BY id DESC LIMIT 5;
漂亮男人2017-06-24 09:44:17
Pinyin to Chinese character conversion solution https://github.com/letiantian...
If there are not many products, you can also add an extra pinyin field