lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shalin Shekhar Mangar <>
Subject Re: get field values from solr and highlight text?
Date Mon, 21 Dec 2009 12:16:09 GMT
On Sun, Dec 20, 2009 at 1:50 AM, Faire Mii <> wrote:

> Ive got the following code.
>    $params = array('defType' => 'dismax', 'qf' => 'threads.title posts.body
>', 'hl' => 'true');
>    $results = $solr->search($query, $offset, $limit, $params);
> So the keywords will be highlighted. What i dont know how to do is pulling
> the data out from $results. How do I get a documents field values and then
> show the body and hightlight it like google/SO search? Im using solr client
> php but i find it difficult to understand how to use it. There is so few
> example codes.

The highlighting response comes as a node separate from the main results but
items in both of them are presented in the same order. You'd need to match
the highlighting snippet with the current document either through the
uniqueKey or through position. So one way to do it would be to read the
snippets out of the response completely and put them in a map with the key
being the unique key and then for each document, lookup the unique key in
the map and print out the highlighted snippet. The other way would be to go
through the result set and highlighting response one item at a time.

Shalin Shekhar Mangar.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message