2017-07-14 103 views
0

我的PHP代码生成的SQL查询如下:SQL全文搜索与CONTAINS引发几何错误

SELECT id, title, files, rating, DATE_FORMAT(date, '%d %M %Y') AS fancydate 
FROM ArtArchive 
WHERE CONTAINS (tags, 'Pepper') 
ORDER BY date DESC 

并返回错误:
HY000 - 3055 - Geometry byte string must be little endian.

标签是一个VARCHAR(255)收录作为FULLTEXT
我得到的查询工作使用:tags LIKE '%Pepper%',所以我肯定CONTAINS的原因。

我想不出这是什么意思的错误,我也有万物几何做什么:我只是试图找到文本

在检查了多个例子之后,我确信我一直在使用正确的语法。我也尝试过诸如:CONTAINS (tags, '"Pepper"'),CONTAINS (tags, 'Pepper'),CONTAINS (tags, "'Pepper'"),没有不同的结果。

我试图不使用IN或LIKE,因为我打算一次在标签字段中搜索多个值。在这个例子中,我已经把它降低到一个值,直到我得到它的工作。

回答

0

MySQL不支持CONTAINS()进行文本搜索,你所期望的:

MySQL only recognizes the CONTAINS SQL function when dealing with spatial data. It requires two graphics objects as arguments, and returns a 1 or 0 depending on if the first object completely contains the second. Designed as an implementation of the OpenGIS framework, the MySQL CONTAINS function does not work on ordinary strings, and will produce an error if you try it. MySQL only recognizes the LIKE and STRCMP functions when dealing with string of information.

研究发现,信息here

+0

我开始觉得包含并不意味着文字,但这么多的在线反例让我希望...这是一个无赖,但感谢清除这一点,我不认为我能找到这个在我自己的。那么最后,我认为没有比一系列“LIKE OR LIKE”更好的选择了吗? – Estecka

+0

是的,https://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html ...或可能https://dev.mysql.com/doc/refman/5.7/en /regexp.html –