Closed (fixed)
Project:
Apache Solr Search
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Apr 2009 at 20:31 UTC
Updated:
17 Jun 2009 at 23:22 UTC
Attached it is a first pass at adding support fro non-cck field data to (a) the indexing process and (b) facet block generation. My test use case was to index some field data from the biblio module, which stores citation data in its own table structure. The hook implementation looks like this:
/*
* Implementation of hook_apachesolr_custom_field_mappings()
*/
function biblio_apachesolr_custom_field_mappings() {
$mappings = array();
$mappings['biblio_secondary_title'] = array(
'index_type' => 'string',
'field_name' => 'biblio_secondary_title',
'label' => t('Biblio Publisher'),
'is_multiple' => FALSE,
'facet' => TRUE
);
$mappings['biblio_contributors'] = array(
'index_type' => 'string',
'field_name' => 'biblio_contributors',
'label' => t('Biblio Contributors'),
'is_multiple' => TRUE,
'callback' => '_biblio_index_contributors',
'facet' => TRUE
);
return $mappings;
}
//helper callback - cram all types of authors into one field
function _biblio_index_contributors($node, $fieldname) {
$contrib = biblio_parse_contributors($node->biblio_contributors);
foreach ($node->biblio_contributors[1] as $contributor) {
$contributors[] = sprintf('%s, %s %s', $contributor['lastname'], $contributor['firstname'], $contributor['initials']);
}
return $contributors;
}
A couple of things to note:
| Comment | File | Size | Author |
|---|---|---|---|
| apachesolr_custom_field_mappings.patch | 12.97 KB | cfennell |
Comments
Comment #1
robertdouglass commentedsee parallel effort: http://drupal.org/node/271753#comment-1516612
Comment #2
pwolanin commentedA custom module can already add data to the index (e.g. the og_apachesolr module is basically example code for this).
Why do we need an additional mechanism?
Comment #3
cfennell commented@pwolanin Thanks, I'll have a look at og_apachesolr - so many positive changes have happened since the last time I looked at this stuff, I should have been more diligent in looking at the additional implementations.
The only thing that looks obvious to me is that the current mechanism is a bit more involved on the API side than a simple hook. But the OG implementation does look pretty clean, and I wouldn't argue for the additional hook (redundant code) solely on this basis.
I'll parse through again and see if there is anything otherwise missing, but your OG example looks very complete.
Marking "by design" just to close this until I have a change to test your API.
Comment #4
fak3r commentedI'm having this same issue, I need Solr to index Authors and Published dates under Biblio; currently it's only looking at Drupal users for authors, and node date for Published dates. I'll take a look at the og_apachesolr module now, but since I've found many posts looking for a similar solution, I wanted this to be reviewed before I set it back to "by design".
Comment #5
pwolanin commented@fak3r are those CCK fields or custom module fields?
Comment #6
fak3r commentedThey are custom module fields, created by Biblio. You can see it in action here: https://www.ethicshare.org/publications/author%253Asmith?author=smith&sc...
Notice down the left gutter there is 'Refine by Author' and 'Refine by Year Published', both being pulled from a Biblio field. So I guess I'm wondering if using apachesolr_og module is the way to build these, and how. If it's not, feel free to close this, but I'm desperately looking for a solution. Thanks
Comment #7
pwolanin commented