Closed Thread Icon

Topic awaiting preservation: How does Google highlight the search terms? Pages that link to <a href="https://ozoneasylum.com/backlink?for=8645" title="Pages that link to Topic awaiting preservation: How does Google highlight the search terms?" rel="nofollow" >Topic awaiting preservation: How does Google highlight the search terms?\

 
Author Thread
Maskkkk
Paranoid (IV) Inmate

From: Willaimsport, PA, US of A the hole in the Ozone
Insane since: Mar 2002

posted posted 05-10-2003 17:54

How does Google highlight their search terms?

for instance like this

Would it be possible to do this when a user clicks on a link to a site to make a point about something?



- Face the Present
- AIM: MASKKKK

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 05-10-2003 23:52

Slime made a script a while ago, if that's what you want.
Check http://www.ozoneasylum.com/Forum1/HTML/007226.html

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 05-11-2003 14:22

It's built in with the Google core software. All v\commercial search engines have it. We had it at Verity too ... the word search index stores the document url and the byte offset for every occurrence of each word in that particular document. After that it's pretty east to cread the document as a bytestream and add a span class= ..... at the correct byte offset, and then (in the case of crude systems) highlight the search term precicely then add the /span tag ... or in the case of ore sophisticated systems (with stemming, soundex, typexetc, and/or theaurus, glossary etc.) to highlight the whole of the word which reflects the search term.


Bug-free software only exisits in two places
A programmer's mind and a salesman's lips

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 05-11-2003 14:46

Here's how I do it in PHP:

code:
if (isset($highlight)){
$highlight = urldecode($highlight);
$body = preg_replace("'$highlight'i","<span class=\"highlight\">\\0</span>",$body);
}


$highlight is grabbed from the URL, urldecoded (strips the "+"), then uses a css class called highlight to actually do the highlighting. An example can be seen at http://www.macombsheriff.com/articles/537/highlight/Pat+Richard

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-11-2003 15:07

Started FAQ:

:FAQ: How do I highlight terms on my page like Google?

___________________
Emps

FAQs: Emperor

Maskkkk
Paranoid (IV) Inmate

From: Willaimsport, PA, US of A the hole in the Ozone
Insane since: Mar 2002

posted posted 05-14-2003 16:51

Alright! Thanks guys! That's what I wanted to know.



- Face the Present
- AIM: MASKKKK

01001101011000010111001101101011011010110110101101101011

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-31-2003 18:19

My mistake...

I neglected to mention that the above link, http://www.macombsheriff.com/articles/537/highlight/Pat+Richard

actually translates to http://www.macombsheriff.com/article.php?aid=537&highlight=Pat+Richard
hence, $highlight is being set to 'Pat+Richard' (please, no gay jokes there...). Then the code I posted takes $highlight and runs with it...

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-01-2003 08:54

wow, pugz... in the past I had neglected to realize how your name could be extremely funny...


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

« BackwardsOnwards »

Show Forum Drop Down Menu