Re: Searching in a long text

From: Date: Sat, 03 Jan 2009 08:50:43 +0000
Subject: Re: Searching in a long text
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-285391@lists.php.net to get a copy of this message
On Sat, 2009-01-03 at 09:26 +0100, Vicente wrote: > Hi all, > > I'm implementing a search tool to find phrases inside a book. > Users will search for some word, then the engine will returns > the 3 or 4 lines containing that word, and giving also the book page > number. > > I have the book in plain text and the doubt is about different > approaches in order to be speedy and saving memory and resources: > > - adding every text page inside fields of one MySQL table. > > - having the whole book as a unique text file, with some marks in > every page to delimit and parse the page number > > > Also, I want to know if there is some possibility to make the same > using PDF files. If it were me, I'd store each line of text in the database along with the page and line number for indexing. Then using full text search I'd retrieve appropriate lines that match the search query. Upon retrieving the matching lines, I'd then proceed to pull the accompanying lines by incrementing/decrementing the line number found and using an IN() clause for matching the various IDs in a single query. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#285391) next »