wp-search-with-algolia icon indicating copy to clipboard operation
wp-search-with-algolia copied to clipboard

Add --post-ids parameter to wp algolia reindex WP-CLI command

Open graham73may opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe. I'm trying to reindex a specific post, or group of posts.

Describe the solution you'd like I would love to be able to trigger a reindex based on a given post id, preferably multiple IDs wp algolia reindex --ids=1,2,3,4,5

Which would also allow something like: wp algolia reindex --ids=$(wp post list --post_type=event --format=ids)

Describe alternatives you've considered wp algolia reindex --all but I've got a lot of content, so it's a very slow workaround.

Additional context It would also be helpful if I could specify a post type and have say, all "events" reindexed.

graham73may avatar Mar 25 '25 12:03 graham73may

Definitely some valid ideas here, especially if you're very intentionally wanting to use the WP-CLI integration we have. For example based on your example, perhaps re-indexing just events on a cron schedule, but not worrying about other content types.

That said, manually updating the posts should be triggering a reindex individually for the item being edited, in case you just have a small handful that you want to get re-indexed.

Leaving this issue open for consideration of WP-CLI enhancements.

tw2113 avatar Mar 25 '25 13:03 tw2113

Yeah it’s just an annoying amount of posts sadly. E.g. 50, with WPML with each in 4 different languages. 200 posts right away!

graham73may avatar Mar 25 '25 13:03 graham73may

Something needing considered here is that we allow for more than just indexing posts, we also allow for taxonomy/terms, and users. So any new flag to specify IDs will also need to have the content type for the IDs.

tw2113 avatar Mar 31 '25 22:03 tw2113

Related: https://github.com/WebDevStudios/wp-search-with-algolia/issues/458

Also we'll want to evaluate which flags can't be used together, for example from what already exists: specifying a specific index + --all

tw2113 avatar Mar 31 '25 22:03 tw2113

Mm fair point. I'm wondering what the "usual" approach is for this scenario with other plugins?

Relevanssi has --post for a single post ID. Struggling to think of any other plugins right now that might cover posts and taxonomies in the same command.

Maybe --posts or --post-ids would be clear? (and --terms?)

graham73may avatar Apr 01 '25 07:04 graham73may

Will most likely do --{$type}-ids=... but want to make sure all is good overall. I know for some "WP All Import" support, we added the ability with posts to specify IDs, which is part of what birthed the #458 ticket, getting things more in sync.

tw2113 avatar Apr 01 '25 12:04 tw2113

Branch: feature/454-post-ids-cli-param

tw2113 avatar Apr 02 '25 21:04 tw2113