I create release notes section for my website where I fetch a paragraph from the specific content type. I have configured one index with fields such as name or status. In addition to that, I added the date field which is part of the paragraph.

I created a view which should display all content data source from this Search API Index.

Everything is ok with the list of hundreds of release notes, release notes are displayed well - but I have problem with sorting.

Firstly, I cannot add sort field on the view page because I can't see any options about the granularity of sorting date (it's only content datasource).

Secondly, I installed module Search API Sorts but it allows the only sort by Integer or String so the field Date is not supported at all.

Thirdly, I put overriding function:

* Implements hook_search_api_solr_query_alter().
function search_api_sorts_search_api_solr_query_alter(Query 
 $solarium_query, QueryInterface $query) {

 $dateField = 'field_publish';
$index = $query->getIndex();
  $fields = $index->getServerInstance()
  $solrField = !empty($fields[$dateField]) ? $fields[$dateField] : '';

  if ($solrField) {
      $solarium_query->addParam('bf', "recip(abs(ms(NOW, {$solrField})),3.16e- 

But I've got error

Error report HTTP Status 400 - can not use FieldCache on multivalued field: dm_field_publish

Do you have any ideas about how to solve this problem or any workaround about sorting paragraphs by date? Thanks in advance!

Your Answer

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

Browse other questions tagged or ask your own question.