On Sun, Dec 20, 2009 at 1:50 AM, Faire Mii <faire....@gmail.com> wrote:
> Ive got the following code. > > $params = array('defType' => 'dismax', 'qf' => 'threads.title posts.body > tags.name', '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. -- Regards, Shalin Shekhar Mangar.