简体   繁体   中英

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

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?

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM