views:

13

answers:

1

on my table I have 3 different FULLTEXT indexes like so:

FULLTEXT KEY `product_name` (`product_name`,`product_description`),
FULLTEXT KEY `product_brand` (`product_brand`,`metal_type`,`primary_stone`,`product_type`,`product_type_sub`,`product_series`),
FULLTEXT KEY `primary_stone_sub` (`primary_stone_sub`)

This is because I added them after the fact like so:

ALTER TABLE cart_product ADD FULLTEXT(columnA, columnB);

Q1 How can I merge these 3 into 1 FULLTEXT index?

Q2 Also, so this doesn't happen again, how would I add a FULLTEXT column to the already existing FULLTEXT index?

Thanks!!!

+1  A: 

It seems like you only want to have 1 FULLTEXT index, containing all of those columns. Is that right? You can also have several FULLTEXT indexes on this table, one containing all of the columns and others containing a subset. It all depends on your usage.

Just remember this caveat from the manual and make sure your fulltext index column list(s) match the columns you are querying against exactly:

  • The MATCH() column list must match exactly the column list in some FULLTEXT index definition for the table, unless this MATCH() is IN BOOLEAN MODE. Boolean-mode searches can be done on nonindexed columns, although they are likely to be slow.

The answer to both questions is that you need to drop the existing index and recreate it with an updated list of columns:

ALTER TABLE cart_product 
  DROP INDEX `product_name`,
  DROP INDEX `product_brand`,
  DROP INDEX `primary_stone_sub`,
  ADD FULLTEXT INDEX `cart_product_fti` (
`product_name`,
`product_description`,
`product_brand`,
`metal_type`,
`primary_stone`,
`product_type`,
`product_type_sub`,
`product_series`,
`primary_stone_sub`
);
Ike Walker
Thanks for the info!
John Isaacks