IDs of referenced entities and their field values are not retrieved from backend

Created on 17 September 2024, 8 months ago
Updated 19 September 2024, 8 months ago

Values of the View's field types SearchApiEntity and SearchApiEntityField are never fetched from the backend even if they exist there and the backend is configured to retrieve data.
That leads to entity loads on search result pages which aren't required.

🐛 Bug report
Status

Active

Version

1.0

Component

General code

Created by

🇩🇪Germany mkalkbrenner 🇩🇪

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mkalkbrenner
  • Merge request !168Resolve #3474967 "Ids of referenced" → (Open) created by mkalkbrenner
  • Pipeline finished with Success
    8 months ago
    Total: 323s
    #285444
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    We just applied that patch to our production systems and it increased the speed of search result views.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    drunken monkey made their first commit to this issue’s fork.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    Thanks for creating this MR, and sorry it took me a while to get back to you.
    If the necessary values are available it is of course important to avoid unnecessary entity loads.

    However, I’m not sure that your code is completely generic. Does it also work if you take the code from \Drupal\search_api\Plugin\views\field\SearchApiFieldTrait::query() and use $this->definition['search_api field'] instead of $this->field? (And send NULL if it doesn’t exist.)
    I’ve pushed an update to your MR, please check it out.

    I think your current code will not work in case of Views field ID conflicts (or renames) and will also incorrectly pass a $field_id for fields that aren’t even indexed (though that will usually not cause any harm, at least with the Solr backend).

Production build 0.71.5 2024