payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
27.66k stars 1.72k forks source link

feat(plugin-search): reindex collections #9391

Open akhrarovsaid opened 1 day ago

akhrarovsaid commented 1 day ago

What?

This PR aims to add reindexing capabilities to plugin-search to allow users to reindex entire searchable collections on demand.

Why?

As it stands, end users must either perform document reindexing manually one-by-one or via bulk operations. Both of these approaches are undesirable because they result in new versions being published on existing documents. Consider the case when plugin-search is only added after the project has started and documents have been added to existing collections. It would be nice if users could simply click a button, choose the searchable collections to reindex, and have the custom endpoint handle the rest.

How?

This PR adds on to the existing plugin configuration, creating a custom endpoint and a custom beforeListTable component in the form of a popup button. Upon clicking the button, a dropdown/popup is opened with options to select which collection to reindex, as well as a useful All Collections option to run reindexing on all configured search collections. It also adds a reindexBatchSize option in the config to allow users to specify in what quantity to batch documents to sync with search.

Big shoutout to @paulpopus for the triple-A level support on this one!

Fixes #8902

See it in action:

https://github.com/user-attachments/assets/ee8dd68c-ea89-49cd-adc3-151973eea28b

Notes: