We want to show the language neutral nodes regardless of the language filter (we have three languages). I tried this approach:
hook_apachesolr_update_index():
if(empty($node->language)) {
$document->language = $node->language = 'neutral';
}
and in hook_apachesolr_modify_query():
$query->add_filter('language', 'neutral');
This results in an empty resultset.
Any help is appreciated.
Comments
Comment #1
mkalkbrennerThat doesn't work because there's no language 'neutral' in the multilingual index.
Apache Solr Multilingual offers a feature to map language neutral content to an existing language. Maybe you can activate a fourth language.
Or implement some hooks to index the neutral node three times using three different languages.
Comment #2
jessehsI used the following code in a custom module's hook_apachesolr_modify_query to achieve this:
Note that I'm using the 6.x-1.0-beta3 version of the apachesolr_multilingual, and the 6.x-1.5 version of the apachesolr module (although this probably works in 2.x too).
*Edit: removed extraneous, unrelated bit of code.
Comment #3
mkalkbrennerComment #4
mkalkbrennerComment #5
mkalkbrennerComment #6
mkalkbrennerComment #8
jessehsI revisited my earlier post, and realized it's not quite right. Here's another shot at this problem:
Comment #9
jessehsHeh, turns out this latest attempt was bad as well. The following is an approach which seems to work:
Comment #10
paul_gregory commentedThanks Jesse, you're a life saver! We had been using your earlier code (#2) but we discovered it wasn't working properly. When I came back to this issue I was pleased to see you'd updated your patch :)
We're now using the code from #9 and it seems to be working brilliantly.