简体   繁体   English

PHP MySQl 搜索引擎建议

[英]PHP MySQl search engine advice

I am trying to make a smart multi-language PHP search engine.我正在尝试制作一个智能的多语言 PHP 搜索引擎。 For example I want to search for samsung smarthphone and the user type in smasung smortphone .例如,我想搜索samsung smarthphone并且用户输入smasung smortphone Which is the best way to extract this from a 1 000 000 rows DB.这是从 1 000 000 行数据库中提取它的最佳方法。 My idea was to select the rows where this REGEXP(for this example) matches我的想法是选择这个 REGEXP(对于这个例子)匹配的行

'[a-zA-z]*[smasung]{4,}[a-zA-Z]*' AND '[a-zA-Z]*[smortphone]{5,}[a-zA-Z]*'

This is selectinh me all the rows that has a word which contains at least 4 or 5 letters of the user input.这是选择所有包含至少 4 或 5 个用户输入字母的单词的行。 But this means to run this regexp at every selected row and then levensteihn the match with the user input and save the best match.但这意味着在每个选定的行上运行这个正则表达式,然后使用用户输入进行匹配并保存最佳匹配。 For 1 000 000 it is pretty slow.对于 1 000 000,它非常慢。 Do you have a better idea?你有更好的主意吗?

I know this problem, so i've exported all my important records to elasticsearch (NoSql and very easy to install).我知道这个问题,所以我已将所有重要记录导出到 elasticsearch(NoSql 并且非常易于安装)。 Next implemented a fuzzy search.接下来实现了模糊搜索。 (build-in) (内置)

{ 
"multi_match" : {  
    "fields" : ["product"],
    "query" : "smasung smortphone",
    "fuzziness" : "AUTO"
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM