I mentioned this to you over the Search Sprint and am only just now getting back to apachesolr. Basically, I'd like to set cck field properties on a per-field basis via your mapping hook. This might look like:
<?php
function apachesolr_cite_apachesolr_cck_field_mappings() {
$mapping['field_creator'] = array(
'index_type' => 'string',
'facet' => TRUE,
);
$mapping['field_subject'] = array(
'index_type' => 'string',
'facet' => TRUE,
'callback' => 'explode_cck_field',
'multiple' => TRUE,
);
return $mapping;
}
function explode_cck_field($node, $key) {
$to_explode = array_pop($node->$key);
$field_parts = explode(" ", $to_explode['view']);
foreach ($field_parts as $field) {
$fields[] = array('view' => $field);
}
return $fields;
}
?>
I've attached a patch that slightly changes the callback to accommodate this finer level of granularity (see above). A few concrete reasons for treating each field individually: (1) automatically indexing and faceting on every field of a given type will be incredibly expensive for Solr, particularly if a given field is very heterogeneous (2) I'd like to be able to assign callbacks on a per-field basis and (3) there may be other things we'd like to tweak for performance or other reasons (ex stored vs indexed only, copy specific fields to text, etc).
Anyway, thanks for supporting this module - we're pretty excited by what you've done already.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | cck-more-granular-271753-17-D6.patch | 5.21 KB | pwolanin |
| #15 | cck-more-granular-271753-15-D6.patch | 3.76 KB | pwolanin |
| #13 | cck-more-granular-271753-13-D6.patch | 2.27 KB | pwolanin |
| #10 | apachesolr_cite_mappings.271753-r2.patch | 4.95 KB | cfennell |
| #5 | apachesolr_mapping.patch | 2.31 KB | cfennell |
Comments
Comment #1
cfennell commentedwhoops, looks like my patch didn't attach...here it is...
Comment #2
cfennell commentedA couple of additions:
I've added a callback to override search parameters that were previously hard-coded. If no search params hook is called the search will use the module defaults you provided.
The CCK mapping also now includes an additional dimension (facet_display) that allows modules to provide custom display settings on a per-facet basis to override the default settings.
With field-level CCK mappings, per-facet display settings and search parameter overrides, I'm just about to Solr nirvana.
The only other modification that I'm contemplating right now is to decouple the Solr block item links from the core search module implementation.
I very much appreciate that you've tied ApacheSolr to core search and allow for a default solr search UI there. But I'd also like to build up multiple search UIs on a per URL basis (ex URLS that don't include module implementation details like "apachesolr_search")...that are not tied directly to core search. In order to do that, I'd need links w/in ApacheSolr-provided blocks to be configurable as well.
But, with the current additions, the callbacks look like:
Thanks.
Comment #3
robertdouglass commentedI've looked at this and have to think about it some more. Can you do me the favor of testing it with the new alpha 3 code and make sure everything applies and works as you expect? Thanks.
Comment #4
robertdouglass commentedNeeds to be evaluated for 1.0 release.
Comment #5
cfennell commentedHi Robert,
Thanks for considering this patch. Sorry for the delay in my response, I just now saw your note. I downloaded and tested the patch against alpha three and the fields were indexed as expected.
Comment #6
cfennell commentedI should have specified that I only tested my patch against 5.x-1.0-alpha3. I'll test 6.x-1.0-alpha3 in the next day or so.
Comment #7
robertdouglass commented@libsys, please test against the .dev versions. We need to get an alpha4 out the door, but until we do, .devs are the best we have to offer.
Comment #8
robertdouglass commentedComment #9
cfennell commentedOk, no problem - I'll take a look at both D5 & D6 tomorrow.
Comment #10
cfennell commentedThe indexing hook failed on DRUPAL-5/dev version - $key was not being properly set in ApacheSolrUpdate. The attached mapping patch now includes a fix for the related $key variable issue. This patch removes the hard-coding of $document variables:
in favor of the dynamic approach taken in alpha3:
Comment #11
robertdouglass commentedJust so you know I've been thinking about this: http://acquia.com/blog/understanding-apachesolr-cck-api
Comment #12
pokadan commentedLooking forward to see a patch working for D6 or perhaps even have it in the next Apache Solr Search Integration release.
Comment #13
pwolanin commentedhere's what I'm thinking for the 6.x module, perhaps.
Comment #14
pwolanin commentedSo, seems like do be maximally granular we need 2 subsets of mappings - per field and per widget.
We check the individual fields first, and then when we are checking a certain widget, we skip it if
isset($fields[$row->field_name])Comment #15
pwolanin commentedComment #16
robertdouglass commentedsee parallel effort: http://drupal.org/node/444320
Comment #17
pwolanin commentedComment #18
pwolanin commenteddiscussed this with Robert - should hopefully be general enough for pretty much any case. If there's a problem, open a new issue.
committing to 6.x
Comment #19
pwolanin commented