0

When someone searches for content from a rich text field, the resulting page does come up in the search. However, the text from the rich text field does not show up in the results.

For example, let's say a page is called "Test" and the rich text field has content that says "King Henry". If I search "king henry", the test page shows up in the results. However, the content from the rich text field does not show with the actual result. How would I go about adding that text to the search results output?

2
  • What do you mean with "the page is found, but the content is not shown?" Do you want more content to be shown in the search results? If that is your question, you can create a variant for search results (or adapt the default one).
    – Gatogordo
    Mar 23 at 16:32
  • @Gatogordo So let's say there is a rich text editor that says, "King Henry" and the page title is "Test". If I search for "King Henry", the page comes up in the search. However, the words king henry do no show up on the search. Mar 23 at 16:37
3

I am assuming you are using the standard (ootb) search results component.

That component is using rendering variants: $site/Presentation/Rendering Variants/Search Results

The default rendering variants will show the title of the page (or the display name). If you want to show extra fields, you should create your own variant that displays this data. Note however that this is using the variant system as all other components, meaning that it can display fields from the "current" item (in this case that is the page/item found with the search query). This variant however is fixed, and will not respond to your search string - so it will not necessarily show the text where the search string was found.

If you need to extend the data (item) that comes from the results, that can be done in the processSearchItems pipeline. In that pipeline you can fill a model per result item and that data can be shown as well with the variants.

Not the answer you're looking for? Browse other questions tagged or ask your own question.