Is it possible to search richtext fields or block fields #15646
-
|
Using the normal UI and the search bar in the list view, is it possible to search for richtext fields or content in block fields? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
By default, Payload's list view search bar only searches fields that are explicitly marked as searchable. Rich text and block fields are not searchable out of the box because their content is stored as structured JSON (not plain text). Option 1: Enable search with
|
| Approach | Effort | Capabilities |
|---|---|---|
listSearchableFields |
Low | Only plain text fields |
| Computed search index | Medium | Rich text + blocks, basic text search |
| Search plugin | Higher | Full search collection, customizable |
For most cases, the computed search index field (Option 2) gives you the best balance of simplicity and power.
Beta Was this translation helpful? Give feedback.
-
|
Hey @snakemastr As @wesleysmyth pointed out, @wesleysmyth's suggestion for computed Add a hidden computed Worth noting too that Payload's search plugin is a frontend only solution. |
Beta Was this translation helpful? Give feedback.
Hey @snakemastr
As @wesleysmyth pointed out,
richTextand block fields aren't searchable via the list view search bar out of the box since their content is stored as structured JSON — the search bar only does basic string matching against flat text fields.@wesleysmyth's suggestion for computed
searchIndexis on the right track, however usingconsolidatedBlockEditorTextwould be a cleaner approach. See below:Add a hidden computed
searchIndexfield that extracts plain text from your Lexical content via abeforeChangehook (usingconsolidatedBlockEditorTextfrom@payloadcms/richtext-lexical) and include it inlistSearchableFields— this works but only gives you basic substring matching at …