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;
}
Files: 
CommentFileSizeAuthor
#8 6x-3x-multiple_snippets.patch579 bytesrbayliss
None View
#5 fix-snippet-overwriting-for-6x2x-1926896-5.patch1.35 KBamirkdv
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix-snippet-overwriting-for-6x2x-1926896-5_0.patch. Unable to apply patch. See the log in the details link for more information. View
#4 1926896-D6.patch1.38 KBkevin.dutra
PASSED: [[SimpleTest]]: [MySQL] 520 pass(es). View
#1 1926896.patch1.49 KBmkalkbrenner
PASSED: [[SimpleTest]]: [MySQL] 513 pass(es). View

Comments

mkalkbrenner’s picture

Status: Active » Needs review
FileSize
1.49 KB
PASSED: [[SimpleTest]]: [MySQL] 513 pass(es). View

here's a patch

kevin.dutra’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

Nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Needs to be committed to 6.x-3.x, pushed to 7.x-1.x branch

kevin.dutra’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.38 KB
PASSED: [[SimpleTest]]: [MySQL] 520 pass(es). View
amirkdv’s picture

FileSize
1.35 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix-snippet-overwriting-for-6x2x-1926896-5_0.patch. Unable to apply patch. See the log in the details link for more information. View

mkalkbrenner's patch backported for 6.x-2.x.

Status: Needs review » Needs work

The last submitted patch, fix-snippet-overwriting-for-6x2x-1926896-5.patch, failed testing.

mkalkbrenner’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)
rbayliss’s picture

Status: Closed (duplicate) » Needs review
FileSize
579 bytes
None View

For 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.