SQL 使用 CONTAINS 进行全文搜索会引发几何错误
SQL fulltext-search with CONTAINS raises geometry error
我的 php 代码生成一个 sql 查询如下:
SELECT id, title, files, rating, DATE_FORMAT(date, '%d %M %Y') AS fancydate
FROM ArtArchive
WHERE CONTAINS (tags, 'Pepper')
ORDER BY date DESC
它 returns 错误:
HY000 - 3055 - Geometry byte string must be little endian.
tags 是一个索引为 FULLTEXT
的 VARCHAR(255)
我使用 tags LIKE '%Pepper%'
使查询正常工作,所以我确定 CONTAINS 是有原因的。
我无法弄清楚这个错误是什么意思,也不知道我与所有事物的 几何 有什么关系:我只是想找到 文本中的单词。
在检查了多个示例之后,我非常确定我一直在使用正确的语法。我还尝试了诸如 CONTAINS (tags, '"Pepper"')
、CONTAINS (tags, 'Pepper')
、CONTAINS (tags, "'Pepper'")
之类的方法,结果没有什么不同。
我尽量不使用 IN 或 LIKE,因为我打算在标签字段中一次搜索多个值。在示例中,我已将其调低为一个值,直到我完全可以使用它为止。
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。
我的 php 代码生成一个 sql 查询如下:
SELECT id, title, files, rating, DATE_FORMAT(date, '%d %M %Y') AS fancydate
FROM ArtArchive
WHERE CONTAINS (tags, 'Pepper')
ORDER BY date DESC
它 returns 错误:
HY000 - 3055 - Geometry byte string must be little endian.
tags 是一个索引为 FULLTEXT
的 VARCHAR(255)
我使用 tags LIKE '%Pepper%'
使查询正常工作,所以我确定 CONTAINS 是有原因的。
我无法弄清楚这个错误是什么意思,也不知道我与所有事物的 几何 有什么关系:我只是想找到 文本中的单词。
在检查了多个示例之后,我非常确定我一直在使用正确的语法。我还尝试了诸如 CONTAINS (tags, '"Pepper"')
、CONTAINS (tags, 'Pepper')
、CONTAINS (tags, "'Pepper'")
之类的方法,结果没有什么不同。
我尽量不使用 IN 或 LIKE,因为我打算在标签字段中一次搜索多个值。在示例中,我已将其调低为一个值,直到我完全可以使用它为止。
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。