Back in #2983606: Provide an excerpt field to use in view modes., we added an Excerpt field that could be used in view modes when rendering search results.
However, the way it was implemented requires each caller of $datasource->viewItem() to manually set $build['#search_api_excerpt'] on the returned array in order for it to work, and we forgot the Views “Rendered item” field.

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new2.16 KB

This should do it.

borisson_’s picture

+++ b/src/Plugin/views/field/SearchApiRenderedItem.php
@@ -112,7 +112,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
-  public function query() {
...
     $this->addRetrievedProperty('_object');

Are we sure this is related?

drunken monkey’s picture

Are we sure this is related?

It isn’t, sorry, just couldn’t help myself once again.
Does it otherwise look good to you?

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Otherwise this looks great, +1

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks for reviewing!
Committed.

  • drunken monkey committed e6640b8 on 8.x-1.x
    Issue #3164255 by drunken monkey, borisson_: Added support for the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ericdsd’s picture

Hi
i couldn't get the excerpt rendered in Rendered item field, i had to switch my view render from field to rendered entity to get the exerpt available on 8.x-1.18.

Note that i've only tested it on media entities.