6

I'm using Apache Solr Search Integration to do the searching on our website, works great except i get results for all the language on the site instead of only the one the user is currently using.

Is there a way to show only nodes that are in the current users language? Either filter it out of the results by a simple check or directly in the query?

I was hoping there would be a hook to alter the results before the pager is created, i got as for as filtering out the other language in hook_apachesolr_search_page_alter() but thats to late, then you get a pager for 3 pages with only one result.

I also tried Apache Solr Multilingual but that doesn't seem the work really well at the moment for 7.x.

8

One way to do this is to implement hook_apachesolr_query_alter() to automatically filter on the current language. In a custom module called "mymodule", the code snippet would look similar to the following:

/**
 * Implement hook_apachesolr_query_alter()
 */
function mymodule_apachesolr_query_alter($query) {
  global $language;
  $query->addFilter("ss_language", $language->language);
}
  • 2
    The above piece of code solves this issue:):) Thanks Chris:) – user4081 Jun 19 '12 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.