Can't search nested Paragraphs Module plain text fields with type Fulltext

Created on 15 January 2025, about 1 month ago

Problem/Motivation

Drupal 10.4.1 , Search API 8.x-1.37

I have an Accordion in a nested Paragraphs Bundle. "Bundle>Accordion Repeater>Accordion Title" or `field_main_bundle:entity:field_accordion_repeater:entity:field_accordion_title`

Accordion Title is a "Text (plain)" field

When I create a View in Drupal with Filter "Fulltext search" I can't search "Accordion Title" specifically and successfully return results.

At "admin/config/search/search-api/index/default_index/fields" I have the Accordion Title field set as Fulltext instead of the default "String".

If I search for a known "Accordion Title: e.g. "Course Info" nothing is returned. See attached screenshots. If I search "Accordion Text" which is a "Text (formatted, long, with summary)" field, search works fine and returns results as expected.

How do I search against "Text (plain)" fields in nested Paragraphs.

Steps to reproduce

Create a nested Paragraphs Module "Text (plain)" field like "Bundle>Accordion Repeater>Accordion Title" and try and search against it as above
See attached screenshots
Thanks

Proposed resolution

Remaining tasks

đź’¬ Support request
Status

Active

Version

1.28

Component

General code

Created by

🇺🇸United States hcanning

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

Comments & Activities

  • Issue created by @hcanning
  • 🇺🇸United States hcanning
  • 🇦🇹Austria drunken monkey Vienna, Austria

    It is known and unfortunate that Paragraphs and Search API don’t play very well together.
    I usually suggest better using just a “Rendered HTML output” field for making the text inside Paragraph entities available for searches – however, in your case it seems you have already done that and it didn’t work.

    The first thing I want to note, though, is that you usually shouldn’t add the “Paragraph” datasource to search indexes. This would only make sense if you want the Paragraphs themselves as search results – usually, however, users want the results to be Content items, and the Content’s Paragraphs included in the indexed fulltext for the content. In that case, you should just use the “Content“ datasource and add fields that point to the fields of the Content’s Paragraphs that you want indexed. (Or, as above, use the “Rendered HTML output” field.)

    That being said, indexing Paragraphs directly should also work, so it’s still unclear why that search wouldn’t work.
    To debug whether the problem is during indexing or during searching, please look into your database, in the search_api_db_default_index_text table. This contains all words indexed for the “Default content index”. By filtering for field_name = 'field_accordion_title' you should see all the words indexed for Accordion titles.

    Anyways, indexing specific fields of Paragraphs is generally not recommended as it is very fragile wrt reorganizing of the Paragraph structure. (When you put that Paragraph into another one, the field will suddenly not be found anymore.) The “Rendered HTML output” field is generally the better solution, if correctly configured (to not include field labels, etc.). But debugging why that doesn’t work in your case is probably even harder, you’d probably need to add debugging code (or an XDebug breakpoint) to \Drupal\search_api\Plugin\search_api\processor\RenderedItem::addFieldValues() to see what’s going on/wrong there.

    In conclusion, this is a pretty site-specific problem so I don’t think I can help you any more than this. You’ll have to debug this yourself, one way or another.

Production build 0.71.5 2024