You are here: Re: Doing a "greedy" search on a db « PHP SQL « IT news, forums, messages
Re: Doing a "greedy" search on a db

Posted by Stefan Rybacki on 09/29/05 14:44

Andrew Poulos wrote:
> I have a db with table that contains a field that I've called
> 'mykeywords' which contains one of more comma separated words. The table
> has 1,000s of rows.
>
> The user can set up to five keywords to search through 'mykeywords' for
> any matches. If the no match is found then a new search is started using
> one less keyword. If that fails a different combination of keywords is
> tried before dropping another keyword. For example, say if the table had
> only one row and the 'mykeywords' field contained:
>
> "house,apple,banana,chair,table,arena,ball,shelf,book"
>
> and a search was started with:
>
> "house,floor,mat"
>
> the search should try (in loose order):
>
> house,floor,mat
> house,floor
> floor,mat
> house,mat
> house
> floor
> mat
>
> My problem is that I'm having trouble finding a way to do a "greedy"
> search (greedy in the sense that I want the largest number of user
> keywords matched) without having to iterate a factorial number of times.
>

Welcome, you've found another example of a NP-complete problem.

You should better search for each key word seperately and combine the found entries if
they are equal and take the entry with the most found words and you get the word
combination you want.


Regards
Stefan



> Andrew Poulos

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация