Change record status: 
Project: 
Introduced in branch: 
8.x-1.x
Introduced in version: 
8.x-1.2
Description: 

#2624876: Add a way to set the fields to retrieve on the query defines a query option for adding the list of properties that the code generating the search results listing will need. This especially allows backends like Solr, which can retrieve result fields directly from the server, to only retrieve the fields that are actually needed. The option will need to be added by the code generating the search query (and, later, the search results) to be supported. The module's Views integration is now already adding the option.

The format of the option is described in \Drupal\search_api\Query\QueryInterface::setOption() as follows:

A list of properties that will be required from results by the code displaying the results list. This option, if present, should be an array keyed by datasource ID and (datasource-internal) property path, with combined property paths as the values. (The "_object" pseudo-property can be used where a whole object (entity or other) is required.)

An example could therefore look like this:

    [
  'entity:node' => [
    'nid' => 'entity:node/nid',
    'title' => 'entity:node/title',
    'uid:entity:_object' => 'entity:node/uid:entity:_object',
  ],
  'entity:file' => [],
  'entity:taxonomy_term' => [
    '_object' => 'entity:taxonomy_term/_object',
  ],
  'entity:user' => [],
  '' => [],
]
Impacts: 
Module developers