2017-07-14 102 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 –