Re: Searching in a long text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux