in reply to Inefficient search algorithm?
Afternoon
How to get a limited number of rows of results back varies from database to database. You didn't mention which database you're using, but in MySQL, for example, the syntax is:
SELECT * FROM foo LIMIT 5, 10;
This would fetch 10 rows, starting from the 5th row. If you're not using MySQL, you'll need to have a quick search, as I can't remember Oracle or Pg off the top of my head.
To make searching any reasonably big corpus of data acceptably fast, you probably need to make use of an index; which is a table of words and phrases matched to the documents that contain them. Looking through every word of every document for every search is just too sloooooow. Take a look at this recent article on perl.com for more info if you're interested in writing your own search engine from scratch in perl.
Alternatively, since writing a search engine is a complicated (though very interesting) exercise, consider using a ready-to-go free search engine that you can install and use on your server, for example Swish-E (perl) or htDig (not perl). I've used the latter with fairly satisfying results.
Lastly, have a search round the monastery, as this kind of thing has been discussed on a few occasions before.
update: added answer to the obvious question at the top. stupid me.
cheers
ViceRaid
|
---|