问题
I like to sort a BOOLEAN
wildcard search by relevance. As BOOLEAN
has only a binary score we need to use the NATURAL
mode to obtain a weight score. But NATURAL
does not support operators so it will not return any results (score = 0):
mysql>SELECT
topic_id,
MATCH(topic_text) AGAINST('tunin') AS score
FROM
topics_search
WHERE
MATCH(topic_text) AGAINST('tunin*' IN BOOLEAN MODE)
ORDER BY
score DESC
LIMIT 10
+----------+----------+
| topic_id | score |
+----------+----------+
| 2 | 0 |
| 6 | 0 |
| 16 | 0 |
| 17 | 0 |
| 18 | 0 |
| 24 | 0 |
| 26 | 0 |
| 27 | 0 |
| 31 | 0 |
| 32 | 0 |
+----------+----------+
10 rows in set (202 ms)
I could use LIKE '%tunin%'
but this won't give me a score.
Question
Is it possible to obtain all the words that are part of the fulltext index, that were hit through the wildcard search?
Example:
mysql>SELECT
fulltext_index_words
FROM
topics_search
WHERE
MATCH(topic_text) AGAINST('tunin*' IN BOOLEAN MODE)
+----------------------+
| fulltext_index_words |
+----------------------+
| tuning |
| tunings |
+----------------------+
2 rows in set (1 ms)
来源:https://stackoverflow.com/questions/42101851/mysql-is-it-possible-to-obtain-words-of-a-fulltext-index