search

Home  >  Q&A  >  body text

How to convert pinyin into Chinese characters or other solutions in the search box of php e-commerce website

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!

迷茫迷茫2701 days ago916

reply all(7)I'll reply

  • 三叔

    三叔2017-06-24 09:44:17

    This requires using a search engine, the database is too heavy

    reply
    0
  • 为情所困

    为情所困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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-24 09:44:17

    Use third-party search support elasticsearch, xunsearch, sphinx and other processing

    reply
    0
  • 巴扎黑

    巴扎黑2017-06-24 09:44:17

    In fact, you can add a pinyin field to the product, which will make the search better

    reply
    0
  • 三叔

    三叔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

    reply
    0
  • 仅有的幸福

    仅有的幸福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;

    reply
    0
  • 漂亮男人

    漂亮男人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

    reply
    0
  • Cancelreply