Dave_Peachy
Dave_Peachy

Reputation: 498

mySQL MATCH AGAINST with contained strings

So i have a problem with mysqls match against.

I need to do something like this:

SELECT somefield FROM my_table WHERE MATCH(somefield) AGAINST ('some 2 x 3');

Where "some 2 x 3" is the thing i'm searching for. But the problem is mysql searches for each word so it will search for 'some', '2', 'x' and '3' and as I can't change ft_min_word_len in my mysql settings this just doesn't work and ignores anything less that 2 characters.

So what i want to do is group the '2 x 3' bit in the query. So it could come out like this???

SELECT somefield FROM my_table WHERE MATCH(somefield) AGAINST ('some {2 x 3}');

This would search for 'some' and '2 x 3'

Is the possible if so how could i do it?

thanks for your help!

Upvotes: 0

Views: 352

Answers (1)

jkrcma
jkrcma

Reputation: 1202

It seems that fulltext isn't the right solution for your request. MySQL won't index the phrase 2 x 3 and even not the word some, because it is on stop words list. I suggest you to extend the query with OR somefield LIKE '%some 2 x 3%' clause to handle these cases where fulltext search is not enough.

Upvotes: 2

Related Questions