php - mysql fuzzy search problem
为情所困
为情所困 2017-05-27 17:38:56
0
6
747

Please tell me how to match the following keywords

For example, the database storage characters are: sfsdf4-1bbsdfsd;

The user inputs 41bb, 4 1bb, and this string can also be matched

How to do this?
Thanks

为情所困
为情所困

reply all(6)
世界只因有你

What you need is not mysql fuzzy search.
Requires search engine support.

洪涛

Create a new field to store the string after removing the special characters that need to be ignored, such as: sfsdf41bbsdfsd. When querying, perform the same operation on the keywords and use the new field to match

左手右手慢动作

MySQL supports regular expression search, such as
SELECT name FROM person_tbl WHERE name REGEXP '^[aeiou]|ok$';

刘奇

I think we should first process the data submitted by the user, divide the data submitted by the user with space dividing lines, form an array, and then use the data in this array to perform fuzzy query, and then retrieve the same data. . . But when a large number of users query in this way, I think your system will be slowed down very slowly, so it is not recommended to use this design pattern

我想大声告诉你

The title question is set to word segmentation search. Direct fuzzy search cannot match the results. Using regular expression search is too inefficient and is not recommended. Moreover, there are too many scenarios. If you develop and implement it yourself, it will be difficult to consider them all. .
It is recommended to use a search engine. Sphinx is very easy to use and supports mysql very well.
The subject of the question has a php tag. If you often use php development, Xunsearch is also good, http://www.xunsearch .com/ Developed by Chinese, the documents are all in Chinese and very convenient to use.

我想大声告诉你

Use a search engine, this is what they do professionally

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template