Skip to content
Michael Beckwith edited this page Oct 23, 2023 · 7 revisions

WP-CLI Algolia commands.

Introduction

WP-CLI is an extensible third party Command Line tool for WordPress.

This plugin ships with WP-CLI commands.

Installation

To setup WP-CLI, please read its official documentation.


If you are using WordPress in a multisite configuration (network enabled), you need to use the --url argument to specify which website you want to execute the command on. If you get the following message: The configuration for this website does not allow to contact the Algolia API., it means you are trying to execute a command on a website that is not configured properly to reach the Algolia API (missing the API keys for example).*


Command: algolia reindex [<indexName>] [--clear] [--all] [--from_batch=#]

The following command will re-index all items belonging to a given index.

If the --all parameter is passed, all enabled indices will be re-indexed.

If the --clear parameter is passed, all existing records will be cleared prior to pushing new records. Also works in combination with the --all parameter.

If the --from_batch parameter is passed with a number, it will start indexing at that specific batch.

Note, you don't need to include the prefix setting value.

# Reindex content for the `posts_post` index...
wp algolia reindex posts_post
# Reindex content for all enabled indices...
wp algolia reindex --all
# Reindex content for all enabled indices, clear existing records first...
wp algolia reindex --clear --all
# Reindex content starting from the 5th batch...
wp algolia reindex --from_batch=5