[BNM] Suggest in search - way of doing with MySQL?

Mark Ng mark at markng.me.uk
Thu Oct 2 15:18:31 BST 2008


First, I'd suggest indexing whatever it is you need to index with some
form of Lucene implementation (Zend has one for PHP).  The mysql full
text indexing is useful in some situations, but it requires myISAM
tables (which aren't always the best move) and Full-Text indexing is a
pain when you have to search across multiple fields and even more so
across multiple tables.  Lucene indexing allows you to prioritise
certain fields (so, for example, you can automatically weight words in
a title field), and does a much better job of relevancy searching.

You can then use levenshtein (as suggested elsewhere) distances to
suggest other words from the index if you want to, but Lucene has this
fuzzy matching already built in, so if you add a tilde to the search
query, it'll use those techniques to do this automatically for you.

HTH,

Mark

2008/10/2 Paul Silver <paul at tenpastmidnight.com>:
> Hi,
>
> I'm making a search within a database driven site soon. We'd like to be
> able to suggest corrections or just show results for the suggestions if
> nothing is returned from a straight search.
>
> E.g. visitor searches for "bananas in pijamas"
>
> Results say: "No results for 'bananas in pijamas', would you like to
> search for 'banans in pyjamas'"
>
> Is there an easy way of doing this with PHP 5 & MySQL 5?
>
> Thanks
>
> Paul
> --
>  Paul Silver - tel: 01273 906020 or mobile: 07813 654285
>  Web Development: http://www.paulsilver.co.uk
>  Search Engine Promotion: http://webpositioningcentre.co.uk
>  Check your web pages: http://www.spidertest.com
>
> --
>
> BNM Subscribe/Unsubscribe:
> http://www.brightonnewmedia.org/options/bnmlist
>
> BNM powered by Wessex Networks:
> http://www.wessexnetworks.com
>


More information about the BNMlist mailing list. Powered by Wessex Networks