I've got a search API search view that has two sorts on it. relevance and then published date. This means that when I do a text search the relevancy score handles the sorting, but when there is no search text, the results are ordered by date. Recently I added some boosting, which has caused that fallback to stop working.

I'm trying to figure out how to remove that first sort (relevance) when there is no search_api_fulltext input.

1 Answer 1


I'm no longer sure if this was a valuable question for the site, but in case my solution helps someone else:

I had recently added a small boost for search results in the current interface language. This boost was causing the issue. Before without a fulltext search value, all results would have the same relevance score, meaning that the sort would fall back to the date. With the boost, all results in the current interface would appear before all results in other languages.

I was adding the language boost with an Event Subscriber listening for SearchApiSolrEvents::PRE_QUERY

I added a conditional to only apply the language boost if the fulltext field search was not empty:

$query = $event->getSearchApiQuery();
if (!empty($query->getKeys())) {
  //apply boost here

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.