Forum Moderators: coopster

Message Too Old, No Replies

Search result preview

         

cdmn

11:33 am on Nov 11, 2007 (gmt 0)

10+ Year Member



Hi,

quick question, how to do search result preview like google does?

------
[link_to_result_page]
word word.... word word [highlight_keyword] word word...
[Revelance]
------

Of course the page is full-text-search indexed. But i cant really understand how to select just 10 words from the whole indexed site with the found phrase...

Some guidelines would be great!

henry0

11:51 am on Nov 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at substring there are a bunch of good examples within the users' comments
substring [us.php.net]

cdmn

5:51 pm on Nov 11, 2007 (gmt 0)

10+ Year Member



yeah, but if use substring my algorithm would be smth like:

i get indexed content from db
parse it with php

I found it a bit lacky 'couse indexed content are long texts and if search will return like 20 result, parsing those with php will be like parsing 20 articles...

Maybe there are more suitable solution when im already matching string in query...

eelixduppy

6:03 pm on Nov 11, 2007 (gmt 0)



You can return a substring using MySQL's string function substr [dev.mysql.com]. This is usually how I do it.

cdmn

6:17 pm on Nov 11, 2007 (gmt 0)

10+ Year Member



Can you provide me with some example query? :)

cdmn

6:22 pm on Nov 11, 2007 (gmt 0)

10+ Year Member



Ok no prob, found answer at [webmasterworld.com ].
Thanks.