Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't SQl MATCH AGAINST find results with only 3 characters in the result?

For Example, I'm search for a person with the last name of Ash so in my query I search for Ash. It will show me people with the last name of Ashley, Ashby etc... but not people with the exact last name of Ash

Here's an example of what my sql looks like:

SELECT * FROM `People`
WHERE MATCH(PersonFirstName, PersonLastName) AGAINST('ash*' IN BOOLEAN MODE) LIMIT 20

Is there some sort of rule that it has to be over 3 characters or something in order for MATCH AGAINST to find it?

like image 476
bigmike7801 Avatar asked Jul 22 '13 20:07

bigmike7801


People also ask

How get last 3 characters name in SQL?

It could be this using the SUBSTR function in MySQL: SELECT `name` FROM `students` WHERE `marks` > 75 ORDER BY SUBSTR(`name`, -3), ID ASC; SUBSTR(name, -3) will select the last three characters in the name column of the student table.

How do you filter a vowel in SQL?

To check if a name begins ends with a vowel we use the string functions to pick the first and last characters and check if they were matching with vowels using in where the condition of the query. We use the LEFT() and RIGHT() functions of the string in SQL to check the first and last characters.

Is there a match function in SQL?

A SQL extension that lets you screen large amounts of historical data in search of event patterns, the MATCH clause provides subclasses for analytic partitioning and ordering and matches rows from the result table based on a pattern you define.


1 Answers

See the system variable ft_min_word_len, which specifies the minimum length of words to be indexed by full-text searching. It defaults to 4, so 3-letter words won't be found by full-text searching. More information about parameters of full-text searching can be found at 12.9.6. Fine-Tuning MySQL Full-Text Search. That page explains:

For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:

[mysqld]
ft_min_word_len=3

Then restart the server and rebuild your FULLTEXT indexes. Note particularly the remarks regarding myisamchk in the instructions following this list.

like image 87
Barmar Avatar answered Oct 20 '22 00:10

Barmar