protected function Highlight::getFulltextFields in Search API 8
Retrieves the fulltext fields of the given result items.
Parameters
\Drupal\search_api\Item\ItemInterface[] $result_items: The results for which fulltext data should be extracted, keyed by item ID.
string[]|null $fulltext_fields: (optional) The fulltext fields to highlight, or NULL to highlight all fulltext fields.
bool $load: (optional) If FALSE, only field values already present will be returned. Otherwise, fields will be loaded if necessary.
Return value
mixed[][][] Field values extracted from the result items' fulltext fields, keyed by item ID, field ID and then numeric indices.
2 calls to Highlight::getFulltextFields()
- Highlight::addExcerpts in src/
Plugin/ search_api/ processor/ Highlight.php - Adds excerpts to all results, if possible.
- Highlight::highlightFields in src/
Plugin/ search_api/ processor/ Highlight.php - Retrieves highlighted field values for the given result items.
File
- src/
Plugin/ search_api/ processor/ Highlight.php, line 361
Class
- Highlight
- Adds a highlighted excerpt to results and highlights returned fields.
Namespace
Drupal\search_api\Plugin\search_api\processorCode
protected function getFulltextFields(array $result_items, array $fulltext_fields = NULL, $load = TRUE) {
// All the index's fulltext fields, grouped by datasource.
$fields_by_datasource = [];
foreach ($this->index
->getFields() as $field_id => $field) {
if (isset($fulltext_fields) && !in_array($field_id, $fulltext_fields)) {
continue;
}
if ($this
->getDataTypeHelper()
->isTextType($field
->getType())) {
$fields_by_datasource[$field
->getDatasourceId()][$field
->getPropertyPath()] = $field_id;
}
}
return $this
->getFieldsHelper()
->extractItemValues($result_items, $fields_by_datasource, $load);
}