I was testing the apachesolr multilanguage module in a 4 language setup for a while now.
apachesolr 6.x-2.0-beta3
apachesolr multilingual 6.x-2.x-dev
I had two errors.
1. double '...' tails the highlighted snippet.
Every snippet got tailed by two times '...' e.g.
search result for lorem ipsum blabalabla ... ...
function theme_apachesolr_search_snippet (in apachesolr_search.module) was ruining my snippets and adding 6 dots where only 3 were needed.
After commenting the following only three dots appeared.
$result .= (strlen($result) > 0) ? ' ... ' : '';
return $result /*. implode(' ... ', $snippets) . ' ...'*/;
2. for some terms snippets dissappear (almost randomly).
After a full index delete and re index all the search results are fine.
After running cron for some terms in some languages the returned results are correct but all snippets are empty. eg.
Lorem [before cache flush]
egestas quis. Pellentesque eu quam at purus dictum sodales pretium eu FRE lorem. In arcu whoopie ipsum ... ...
Lorem [after cache flush]
...
In function theme_apachesolr_search_snippet (in apachesolr_search.module)
there is a test built in that test on $snippets['body'] however the snippets returned have the language in the key in another way:
like so: $snippet['body_de'] = "MYSNIPPET".
To make this work i added some test on the language in this snippet.
see below.
function theme_apachesolr_search_snippets($doc, $snippets = array()) {
global $language;
$result = '';
if (isset($snippets['body'])) {
$result .= $snippets['body'];
unset($snippets['body']);
}
/**** NEW CODE **/
if (isset($snippets['body_'.$language->language])) {
$result .= $snippets['body_'.$language->language];
unset($snippets['body_'.$language->language]);
}
/**** END NEW **/
if (isset($snippets['teaser'])) {
...
is this the consequence of some misconfiguration?
Is this something i did wrong?
Please advise.
Comments
Comment #1
wouters_f commentedWhen i do the query manually, i can see that when searching lorem (with filter on language:de) the following happens:
1. the document is correctly returned, with body_ for 4 languages
2. the snippets have a body_ for the three other languages and a spell_ for all 4 languages.
what is the problem here?
When I override my params[hl.fl] with spell_"language" my snippets are complete for all 4 languages.
What am I doing wrong that snippets ( the body_xx key) are not returned in all 4 languages?
Comment #2
wouters_f commentedThis hook solved my hidden snippets:
I dont know if this is aestethically correct but it works for me.
I added the body field to highlight parameters. in the apachesolr_modify query hook.
function MYMODULE_apachesolr_modify_query(&$query, &$params, $caller) {
$list = explode(',',$params['hl.fl']);
if(!in_array("body",$list))
{
$list[] = "body";
}
$params['hl.fl'] = implode(',',$list);
}
Comment #3
wouters_f commentedComment #4
mkalkbrennerHighlighting rewrite is on our TODO list