Index: apachesolr_biblio.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr_biblio/apachesolr_biblio.admin.inc,v retrieving revision 1.1 diff -u -p -r1.1 apachesolr_biblio.admin.inc --- apachesolr_biblio.admin.inc 23 Sep 2009 12:18:20 -0000 1.1 +++ apachesolr_biblio.admin.inc 6 Nov 2009 10:23:42 -0000 @@ -1,5 +1,5 @@ {$biblio['name']}, $biblio['index_type'])) { if (is_array($value)) { + // The $biblio_sort variable exists just to build the $sort_index_key. + // The $sort_index_key exists so that results can later be sorted + // by the first value of this field. Citations often have many + // values for fields and we therefore use the first value as the + // sort value, building a special field just for this purpose. + // TODO: Add a checkbox on the field configuration screen that + // indicates whether a field should have a sort, or not. + // TODO: Add sorts to the $query object. + $biblio_sort = FALSE; + if ($biblio['multiple']) { + $biblio_sort = $biblio; + $biblio_sort['multiple'] = FALSE; + $sort_index_key = apachesolr_index_key($biblio_sort); + } + $first = TRUE; foreach($value as $v) { + if ($first) { + $document->$sort_index_key = $v; + $first = FALSE; + } $document->setMultiValue($index_key, $v); } } @@ -78,10 +97,19 @@ function apachesolr_biblio_apachesolr_up // Handle authors. if (variable_get('apachesolr_biblio_index_authors', 1)) { $value = array(); - foreach ($node->biblio_contributors as $keys) { - foreach ($keys as $key) { - if (isset($key['name'])) { - $document->setMultiValue('sm_biblio_contributors', apachesolr_clean_text($key['name'])); + + foreach ($node->biblio_contributors as $arrays) { + $first = TRUE; + foreach ($arrays as $contributor_node) { + if (isset($contributor_node['name'])) { + if ($author = trim(apachesolr_clean_text($contributor_node['name']))) { + if ($first) { + // Set the first name to ss_biblio_first_author + $first = FALSE; + $document->ss_biblio_first_author = $author; + } + $document->setMultiValue('sm_biblio_contributors', $author); + } } } }