在PHP / MySQL中实现拼写错误的最佳方法是什么? [英] What's the best way to implement typo correction into a search in php/mysql?

查看:133
本文介绍了在PHP / MySQL中实现拼写错误的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站列出电影。当然,人们在搜索电影时会犯拼写错误,当然也有一些电影有撇号,用字母拼出标题中的数字等等。

如何让我的搜索脚本忽略这些错误?可能需要的东西比 WHERE mov_title LIKE'%keyword%'



更智能一些。我使用全文搜索引擎,但所有这些看起来都非常复杂,我觉得将它们构建到我的应用程序中将会像地狱一样。如果我确实需要使用一个,那么最不具有侵入性的一个是什么,那么在现有代码中实现将会非常轻松? 解决方案

我认为你必须实现一个外部全文搜索引擎。 MySQL只是不擅长全文搜索。我会说你应该给 Lucene 一个去(教程)。 Zend Framework有一个API,可以插入到Lucene中,使它更容易学习和利用。

I have a site that lists movies. Naturally people make spelling mistakes when searching for movies, and of course there is the fact that some movies have apostrophes, use letters to spell out numbers in the title, etc.

How do I get my search script to overlook these errors? Probably need something that's a little more intelligent than WHERE mov_title LIKE '%keyword%'.

It was suggested that I use a fulltext search engine, but all of those things look really complicated, and I feel that building them into my application will be like hell on earth. If I do have to use one, what's the least invasive one, that will be most painless to implement into existing code?

解决方案

I think you'll have to implement an external fulltext search engine. MySQL just isn't good at fulltext search. I'd say you should give Lucene a go (tutorials). Zend Framework has an API that plugs into Lucene, making it easier to learn and utilize.

这篇关于在PHP / MySQL中实现拼写错误的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆