mysql全文搜索错误

发布于 2024-10-17 04:28:34 字数 242 浏览 4 评论 0原文

我尝试将全文搜索添加到现有表中。当我尝试时:

alter table tweets add fulltext index(tags);

我收到错误:

ERROR 1214 (HY000): The used table type doesn't support FULLTEXT indexes

问题是什么?我如何知道它是什么表类型?

I try to add full text search to an existing table. When I tried:

alter table tweets add fulltext index(tags);

I got the error:

ERROR 1214 (HY000): The used table type doesn't support FULLTEXT indexes

what is the problem? How can I know what table type it is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

套路撩心 2024-10-24 04:28:34

如果您想使用全文索引,您需要确保表的底层引擎是 MyISAM。您可以使用 ALTER TABLE tweets ENGINE = MYISAM; 来更改此设置

If you want to use full text indexing you need to make sure your table's underlying engine is MyISAM. You can change this using ALTER TABLE tweets ENGINE = MYISAM;

时光无声 2024-10-24 04:28:34

这是检查表类型的方法:

SELECT table_schema,engine FROM information_schema.tables WHERE table_name='tweet';

只有 MyISAM 支持 FULLTEXT 索引

您可能还想抢占停用词列表。

单击此处查看全文索引 通常会忽略。

您可以按如下方式覆盖它:

1) 在 /var/lib/mysql 中创建一个文本文件,如下所示

echo "a" > /var/lib/mysql/stopwords.txt<BR>
echo "an" >> /var/lib/mysql/stopwords.txt<BR>
echo "the" >> /var/lib/mysql/stopwords.txt<BR>

2) 将其添加到 /etc/my .cnf

ft_stopword_file=/var/lib/mysql/stopwords.txt<BR>
ft_min_word_len=2

3) service mysql restart

这里还有一些需要考虑的事情:

您可能不想将表 'tweets' 转换为 MyISAM

1) 如果 InnoDB 表“tweets”包含 CONSTRAINT(s)

2) 如果 InnoDB 表 'tweets' 是其他 InnoDB 表的父级,并且外键约束返回到 'tweets'。

3) 您无法承受“tweets”表的表级锁定。

请记住,如果“tweets”表是一个 MyISAM 表,则每次 INSERT 都会触发表级锁定。由于它当前是一个 InnoDB 表(执行行级锁定),因此可以非常快速地INSERTed 到“tweets”表中。

您可能希望创建一个名为 tweets_tags 的单独的 MyISAM 表,该表具有与“tweets”表相同的主键以及 TEXT 列称为“标签”,与“推文”表中的名称相同。

接下来,像这样初始加载 tweets_tags:

INSERT INTO tweets_tags (id,tags) SELECT id,tags FROM tweets;

然后,定期(每晚或每 6 小时)将新推文加载到 tweets_tags 中,如下所示:

INSERT INTO tweets_tags (id,tags) SELECT id,tags FROM tweets WHERE id > (SELECT max(id) FROM tweets_tags);

This is how you check the table type:

SELECT table_schema,engine FROM information_schema.tables WHERE table_name='tweet';

Only MyISAM supports FULLTEXT Indexes.

You may also want to preempt the stopword list.

Click Here for the Stop Words that FullText Indexing Would Normally Ignore.

You can override this as Follows:

1) Create a text file in /var/lib/mysql like this

echo "a" > /var/lib/mysql/stopwords.txt<BR>
echo "an" >> /var/lib/mysql/stopwords.txt<BR>
echo "the" >> /var/lib/mysql/stopwords.txt<BR>

2) Add this to /etc/my.cnf

ft_stopword_file=/var/lib/mysql/stopwords.txt<BR>
ft_min_word_len=2

3) service mysql restart

Here is something else to consider:

You may not want to convert the table 'tweets' to MyISAM.

1) If the InnoDB table 'tweets' contains CONSTRAINT(s).

2) If the InnoDB table 'tweets' is the parent of other InnoDB tables with Foreign Key Constraints back to 'tweets'.

3) You cannot afford to have table-level locking of the 'tweets' table.

Remember, each INSERT into the 'tweets' table will trigger a table-level lock if it were a MyISAM table. Since it currently an InnoDB table (which does row-level locking), the 'tweets' table can be INSERTed into very quickly.

You many want to create a separate MyISAM table, called tweets_tags, with the same Primary Key of the 'tweets' table along with a TEXT column called 'tags' the same as in the 'tweets' table.

Next, do an initial load of tweets_tags like this:

INSERT INTO tweets_tags (id,tags) SELECT id,tags FROM tweets;

Then, periodically (every night or every 6 hours), load new tweets into tweets_tags like this :

INSERT INTO tweets_tags (id,tags) SELECT id,tags FROM tweets WHERE id > (SELECT max(id) FROM tweets_tags);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文