Skip to content

Commit

Permalink
Issue #3402831 by codebymikey, mkalkbrenner: [sorting] Always set the…
Browse files Browse the repository at this point in the history
… multivalue's first value as long as it's not NULL
  • Loading branch information
codebymikey authored and mkalkbrenner committed Nov 21, 2023
1 parent d0e01a4 commit c6ff0b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Plugin/search_api/backend/SearchApiSolrBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ public function getDocuments(IndexInterface $index, array $items, UpdateQuery $u
}

// Enable sorts in some special cases.
if ($first_value && !array_key_exists($name, $special_fields)) {
if (($first_value !== NULL) && !array_key_exists($name, $special_fields)) {
if (
strpos($field_names[$name], 't') === 0 ||
strpos($field_names[$name], 's') === 0
Expand Down Expand Up @@ -2636,7 +2636,7 @@ protected function hasHierarchicalProperties(EntityDataDefinitionInterface $prop
* @param array $boost_terms
* Reference to an array where special boosts per term should be stored.
*
* @return bool|float|int|string
* @return bool|float|int|string|null
* The first value of $values that has been added to the index.
*/
protected function addIndexField(Document $doc, $key, array $values, $type, array &$boost_terms) {
Expand All @@ -2647,11 +2647,11 @@ protected function addIndexField(Document $doc, $key, array $values, $type, arra
if (empty($values)) {
if ('text' !== $type || !$this->configuration['index_empty_text_fields']) {
// Don't index empty values (i.e., when field is missing).
return '';
return NULL;
}
}

$first_value = '';
$first_value = NULL;

// All fields.
foreach ($values as $value) {
Expand Down

0 comments on commit c6ff0b7

Please sign in to comment.