FULLTEXT INDEX with empty string in boolean mode giving error "syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*'"

Viewed 97
MATCH (a2.name, a2.email) AGAINST ("key*" IN BOOLEAN MODE) //this works
MATCH (a2.name, a2.email) AGAINST ("*" IN BOOLEAN MODE) //doesn’t work 

one option that I have is to write 2 queries on basis of key presence. Is there any other option available?

1 Answers

Your application must observe that the user provided an empty string and do something different than blindly throwing it into AGAINST. In this case, leaving the FT clause out of the WHERE might be 'right', but possible 'slow'.

Also you may want to avoid 1- and 2-character strings. And strings with punctuation. And stop words.

Sometimes it is wise to revert to LIKE '%foo%' when the user provides something that you can predict that FT will "do wrong".

Related