1

We're using Search API Autocomplete with Search API 7.x-1.9 on a site set up with Solr (Websolr) serving nodes in both English and German.

I'm looking to be able to filter the results by ss_search_api_language field which is presently not happening and as such i get autocomplete results for all both languages.

What would be the correct approach to deal with this?

0

This issue has been fixed by fons vandamme via the drupal module issue tracker

function filter_by_language_search_api_query_alter(SearchApiQueryInterface $query) {
  //if query is of type search_api_autocomplete we will add our extra language filter
  if (strpos($query->getOption('search id'), 'search_api_autocomplete:') !== false) {
      dsm($query->getOption('search id'));


      global $language;


      $filter = $query->createFilter('AND');
      $filter->condition('language', $language->language, '==');
      $query->filter($filter);


  }
}

Make sure the language of your nodes are in the index.

https://www.drupal.org/node/2166113

  • Nice answer but it should be '=' and not '=='. – Kodiak Mar 9 '15 at 14:29

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.