3

MySQLフルテキストとPHP(codeigniter)を使用して、RSSアイテムを含むデータベースを検索しています。問題は、これらのアイテムのタイトルの一部がスペースの代わりにアンダースコアを使用していることです。MySQLはアンダースコアを単語の一部と見なすため、ユーザーがアンダースコアを含む正確なタイトルを入力しない限り、これらの項目が検索で一致することはありません。

サーバーは共有されているため、MySQLサーバーのシステム変数にアクセスできません。

この動作を他の方法で変更できますか?これは、検索クエリ自体を介して実行できますか?

DB内のすべてのアンダースコアの出現箇所をスペースで置き換えることができることはわかっていますが、これにより、これらのタイトルの元の整合性が損なわれる可能性があります。これを行う別の方法があるかどうか疑問に思っています。

4

2 に答える 2

1

I don't think this can be done without access to the server. The only way I have ever seen to do it is the first comment on this mySQL manual page ("How I added '-' to the list of word characters"). It requires stopping the server and changing internal configuration.

Your best bet is probably creating a second column with removed underscores, and to search that.

于 2010-02-12T11:56:44.360 に答える
1

I know I could just replace all underscore occurrences in the DB by spaces, but this would compromise the original integrity of those titles though. Just wondering if there's another way of doing this.

You can instead of replacing underscores in original title field, use a separate field dedicated to fulltext searches.

This allows you to replace underscores, plus aggregates keywords into this field (category names, authors, tags, etc.) to enhance search results relevance. We used this a lot of times with success for getting rid of HTML tags in content infering with search

于 2010-02-12T12:22:29.020 に答える