Download & Extend

Make the $results array that comes back from a search more useful.

Project:Apache Solr Search Integration
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

In particular I used modify_query to add a field to the $params['fl'] and was disappointed that the field wasn't automatically available to me in the search results. It was, in fact, available, but only through the badly named 'node' element of the array which contained the Apache_Solr_Document. I could have used the $result['node']->getField('blah'); method but imo this assumes too much knowledge of the phpclient library.

To make it easier to deal with this patch does two things.

1. renames 'node' to 'document'. Note that this creates some mismatch between the array and the theme layer. If it causes problems we have to address the theme layer.

2. iterates over the Apache_Solr_Document and makes an array of its fields called $result['fields'] for easy access.

AttachmentSizeStatusTest resultOperations
results.patch1 KBIgnored: Check issue status.NoneNone

Comments

#1

Here's a version without renaming node->document. A little less disruptive.

AttachmentSizeStatusTest resultOperations
results.patch879 bytesIgnored: Check issue status.NoneNone

#2

Version:6.x-2.x-dev» 6.x-1.x-dev

Committed to DRUPAL-6--2. Marking to be ported.

#3

Status:needs review» patch (to be ported)

#4

Version:6.x-1.x-dev» 5.x-2.x-dev

Here's a patch for 5.x-2.x-dev.

Note that I've also moved the comment count generation ($extra[] = format_plural($doc->comment_count, '1 comment', '@count comments');) above drupal_alter('apachesolr_search_result', $doc); (as is in 6.x-2.x-dev) so modules can alter also that value. I think this should also be fixed in 6.x-1.x-dev.

AttachmentSizeStatusTest resultOperations
apachesolr-623046-D5.patch2.3 KBIgnored: Check issue status.NoneNone

#5

Claudiu - better not to mix up two things in one patch. Can you start a new issue with the shuffling of the $extra and drupal_alter?

#6

Sure... Here's the patch for 5.x-2.x-dev

AttachmentSizeStatusTest resultOperations
apachesolr-623046_1-D5.patch2.56 KBIgnored: Check issue status.NoneNone

#7

Version:5.x-2.x-dev» 6.x-1.x-dev

Committed in DRUPAL-5--2, #317518

Switched for backporting in 6.x-1.x-dev.

#8

I don't think you actually have to use the getField() method.

#9

Status:patch (to be ported)» needs review
AttachmentSizeStatusTest resultOperations
623046-better-results-6x-1x-9.patch1.12 KBIgnored: Check issue status.NoneNone

#10

Status:needs review» fixed

committed to 6.x-1.x

#11

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.