问题
In Mysql (Innodb) I have created a FULL-TEXT index.
Is there a query I can use to retrieve a list of all words contained in the full-text index?
My idea is to use a text field that hold a json dump of a list of TAGS.
Than I can use full-text query to retrieve rows matching tags (it works).
The problem left is to retrieve a list of indexed tags to implement a suggestion and auto completion tag input field.
回答1:
Set innodb_ft_aux_table mysql server variable at runtime to your innodb table containing the fulltext index. This will cause the INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE to be populated. This table contains a word
column containing
word extracted from the text of the columns that are part of a FULLTEXT
You can use select query to ge the list of words from this table. However, this setting is recommended for testing / debugging purposes only, so I would not really use it in a live environmnet.
Another catch with this approach is the minimum length of words being indexed and the stopword list. If a tag is shorter than the minimum word length, it is not going to be indexed. If the tag name is on the stopword list, it will not be indexed.
To be honest, I would rather create a separate table where you maintain the list of tags and would use that as a source for the auto complete.
来源:https://stackoverflow.com/questions/34945523/list-words-indexed-by-innodb-fulltext