Retrieve fields from ResultRow if available.

Created on 17 January 2025, about 2 months ago

Problem/Motivation

By default when field data is retrieved (especially for custom fields) addFieldValues method is called for each field even though ResultRow may contain field value. Especially when Retrieve result data from Solr is enabled.

Proposed resolution

Implement a setting on field level e.g. \Drupal\search_api\Plugin\views\field\SearchApiFieldTrait::defineOptions, \Drupal\search_api\Plugin\views\field\SearchApiFieldTrait::buildOptionsForm, etc. that would allow for user to specify if field value can be retrieved from index instead of using addFieldValues which is usually contains some heavy compute code.

📌 Task
Status

Active

Version

1.0

Component

Views integration

Created by

🇺🇦Ukraine dinazaur

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dinazaur
  • 🇦🇹Austria drunken monkey Vienna, Austria

    The code in SearchApiFieldTrait is unfortunately very complex, but in theory there should already be code that ensures that fields will only be extracted if they are not yet set on the result row – see the code determining $required in \Drupal\search_api\Plugin\views\field\SearchApiFieldTrait::getValuesToExtract().
    But it’s entirely possible that there are holes in that code. Still, as it’s probably rather specific to your setup, it would be great if you could determine where the code is going wrong and which additional checks might help.

    I don’t think we need a new option for this, as this is already what we’re trying to do. It’s just fixing the existing functionality.

Production build 0.71.5 2024