I am using search api solr and using views for search results. In my content type, there will be a multilingual field using entity translation and also a field representing language of the node. I am having three languages in the site.

I would like to sort the results by language.

Like, if the site language is set to english,

The search results should first list all english language nodes and then second language and then third. Suggest me a way to fix this.

1 Answer 1


I fixed this by using hook_search_api_solr_query_alter() and solr function. Here is my code:

function mymodule_search_api_solr_query_alter(array &$call_args, SearchApiQueryInterface $query) { if ($_SESSION['language'] == 'en') { $call_args['params']['sort'] = 'termfreq(ss_field_name,EN) desc'; } }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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