The highlighting result of solr looks like this:
<lst name="highlighting">
<lst name="hash/node/6">
<arr name="content">
<str>First hightlighted snippet.</str>
<str>Second hightlighted snippet.</str>
<str>Third hightlighted snippet.</str>
</arr>
</lst>
</lst>
The parsing code looks like this:
foreach ($response->highlighting->{$doc->id}->$hl_param as $values) {
$snippets[$hl_param] = $values;
}
The result is, that the value of $snippets[$hl_param] will be overridden two times and finally contain the "Third highlighted snippet.".
Basically the parsing code need to be something like
foreach ($response->highlighting->{$doc->id}->$hl_param as $value) {
$snippets[$hl_param][] = $value;
}
Comments
Comment #1
mkalkbrennerhere's a patch
Comment #2
kevin.dutra commentedI can vouch that this code change works for 6.x-3.x. I don't have a D7 install to test, but the relevant sections of code appear to be identical between 7.x-1.x and 6.x-3.x.
Comment #3
nick_vhNeeds to be committed to 6.x-3.x, pushed to 7.x-1.x branch
Comment #4
kevin.dutra commentedComment #5
amirkdv commentedmkalkbrenner's patch backported for 6.x-2.x.
Comment #7
mkalkbrennerThis issue has already been solved for 6.x-3.x by #1946132: ERROR: Warning: implode() [function.implode]: Invalid arguments passed in theme_apachesolr_search_snippets() (line 1708 of...).
Comment #8
rbayliss commentedFor what it's worth, this hasn't totally been fixed, at least in 6.x-3.x. It's also a separate issue from the one that was linked to (that was about fixing the error when you pass multiple snippets to the theme function, this one is about accepting multiple snippets from Solr). Currently only the first snippet is used. Attached patch passes all of the returned snippets down to the theme function.