3

I want to update search results as the user types.

I'm using MATCH to compare search terms with rows. MATCH is great because it's not case sensitive and it treats accented characters as regular characters.

My problem for this implementation is that it only find results if the user typed the full word.

E.G: If the user types `arbol` MATCH finds all similar rows (árbol, Arbol etc)
however when he just typed `árb` MATCH doesn't find any results.

How should I write the WHERE clause so it shows all occurences whether is in a string or substring?

1
  • I believe case sensitivity is dependent on your collation. Commented Jun 13, 2020 at 9:29

2 Answers 2

5

Appending a wildcard (*) to your match string should do what you want.

WHERE MATCH (columnName) AGAINST ("term*");

EDIT: oh, and you'll need:

IN BOOLEAN MODE

as well to use wildcard matching.

Sign up to request clarification or add additional context in comments.

Comments

1

MySQL MATCH uses Full Text searching, which has a default minimum 4-character requirement.

The minimum and maximum lengths of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. (See Section 5.1.3, “Server System Variables”.) The default minimum value is four characters; the default maximum is version dependent.

Reference: http://dev.mysql.com/doc/refman/5.5/en/fulltext-fine-tuning.html

1 Comment

Users would need to type at least four characters or more to get a match. You can edit the variables mentioned to decrease this limit, but it comes with a performance penalty.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.