I have mysql community 5.6.13 on 2 mac laptops - one with os x 10.8 and another with os x 10.9.
As far as I can tell, the installations of mysql are the same but the same full text search behaves differently on each installation.
The query I have is:
SELECT legal_matter.* FROM legal_matter
left join user_account
on user_account.id = legal_matter.lawyer_id
left join client_account
on client_account.id = legal_matter.client_account_id
WHERE MATCH (legal_matter.question) AGAINST ('[email protected]' IN BOOLEAN MODE)
OR user_account.username like '%[email protected]%'
OR legal_matter.display_name like '%[email protected]%'
OR client_account.company_name like '%[email protected]%'
On the laptop with 10.8, the query executes normally, on the laptop with 10.9, the query complains:
Error Code: 1064. syntax error, unexpected '@', expecting $end
TI have no idea if it has anything to do with the different OS versions, I suspect not but am at a loss as to what the issue is.
Any pointers gratefully received.
Thanks.
The basic query format of full-text searches in MySQL should be similar to the following: SELECT * FROM table WHERE MATCH(column) AGAINST(“string” IN NATURAL LANGUAGE MODE); When MATCH() is used together with a WHERE clause, the rows are automatically sorted by the highest relevance first.
Full-text indexes can be used only with MyISAM, Aria, InnoDB and Mroonga tables, and can be created only for CHAR, VARCHAR, or TEXT columns.
MySQL has support for full-text indexing and searching: A full-text index in MySQL is an index of type FULLTEXT . Full-text indexes can be used only with InnoDB or MyISAM tables, and can be created only for CHAR , VARCHAR , or TEXT columns.
Using the LIKE operator gives you 100% precision with no concessions for recall. A full text search facility gives you a lot of flexibility to tune down the precision for better recall. Most full text search implementations use an "inverted index".
I had queries that used match against email which started failing when I switched to innodb since @ is used to search for words a certain distance apart in InnoDB:
SELECT username FROM users WHERE MATCH(user_email) AGAINST('[email protected]' IN BOOLEAN MODE);
ERROR 1064 (42000): syntax error, unexpected '@', expecting $end
SELECT username FROM users WHERE MATCH(user_email) AGAINST("[email protected]" IN BOOLEAN MODE);
ERROR 1064 (42000): syntax error, unexpected '@', expecting $end
mysql>
Try wrapping your email address like this:
SELECT username FROM users WHERE MATCH(user_email) AGAINST('"[email protected]"' IN BOOLEAN MODE);
or escaped:
SELECT username FROM users WHERE MATCH(user_email) AGAINST('\"[email protected]\"' IN BOOLEAN MODE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With