PHP MYSQL FULLTEXT how to do an exact search?

I am doing a PHP search for MYSQL FULLTEXT, but how to do an exact search? Since I am using some of the following code, I need to return data that should contain the words "new" and "york", em ... actually the code will return some data that contains only "new" but never have "york" . As?

SELECT * FROM text WHERE MATCH (title,body) AGAINST('new+york' IN BOOLEAN MODE) 
+4
source share
2 answers

Although Charles is right about the length of the word β€œnew”, there is another problem here β€” even reindexing with a shorter minimum word length (not quite practical), you will get content containing the words β€œnew” and β€œnew”, york and a lot of words between them, but not necessarily just the string "New York".

In addition, there is a good chance that the word β€œnew” is in more than 50% of your records, so records for it are not returned.

I came up with a way to enable exact matching of strings with full-text indexes a couple of years ago - although I never got around to including logical search mode as well.

+1
source

You stumbled upon a regional case - the problem is not what you think.

Full-Text Indexing By default, MySQL will not index words up to four characters in length, such as "new" . "new" If you want to find "new" , you need to adjust the minimum word length and rebuild your indexes.

+2
source

Source: https://habr.com/ru/post/1347180/


All Articles