开发者

Searching and and ampersand

I have a php/mysql directory. If someone searches a company name like "Johnson & Johnson" and it's it the DB as "Johnson and Johnson" it doesn't match.

I'm doing a NAME LIKE '% var %' 开发者_运维百科kind of search currently. Is there an easy way to get this to work? I'm not sure if it's just a matter of setting up the table as INNODB with full text on the column or if there's more involved.

Thanks, Don


Yeah, you need a more sophisticated search capable of tokenising the search terms and searching through a tokenised index. You could probably get some of the way there with a full text search in the InnoDB table engine, but you could also look at other options. Some that you could consider:

  • Sphinx
  • Lucene
  • Solr
  • Nutch

All of these are more sophisticated full text indexers and searchers than you will get built into a database engine, but will require more work to get set up and going than a mysql full text search too, so it depends on the features you need.


Replacement of & by and is not really a trivial task in my book.

You may fare better by doing that kind of replacement beforehand, using a set of pre-defined rules (e.g. "&" and "+" become "and").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜