I have a FULLTEXT index called cart_product_fti on a table
Whenever I use it, I have to list all the fields that are in the index exactly:
MATCH (foo,bar,etc)
My thoughts are, if later I decide to add/remove a field to the index, all the scripts are going to have to be updated or they will be broken.
So I am wondering if there is a way to get a list of all the fields in the index and then insert the list into my MATCH() so it won’t have to be updated if a change is made to the FULLTEXT index?
Possible solutions:
Just do the work. A properly structured project probably has just 1 or 2 classes or files with the specific query / datarelation, so it shouldn’t be that much work.
Keep on querying information_schema.statistics again and again for every query to build a query dynamically (hardly efficient).
Define a stored procedure which searches in the table, in which case altering the table / fulltext index layout would only require you to alter the procedure once.
Edit: for some reason key_column_usage doesn’t seem to hold a FULLTEXT reference, and we have to resort to the information_schema.statistics table?