WP CLI commands

Ajax Search Pro WordPress command line commands list

Ajax Search Pro offers a WP CLIarrow-up-right integration. WordPress Command line is a convenient way to do various tasks without the browser.

To list all Ajax Search Pro related sub-commands run:

wp asp

To get help for a specific subcommand, run:

wp help asp <subcommand>

Index Table Commands

The index table subcommand lets you create, maintain and get information about the search index.

Command synopsis

wp asp index <new|continue|delete|item|info> [--batch=<batch>]
  [--skip-confirm] [--post_id=<post_id>] [--check-responsiveness]
  [--sleep=<milliseconds>] [--separate-process]

To get all the parameters and flags directly in the command line run:

wp help asp index

Command flags

Flag
Description

--skip-confirm

Skips the confirmation dialog when creating a new index or when deleting it.

--batch=<batch>

Number of posts (items) to index within an iteration step. Defaults to the number set on the plugin back-end.

--check-responsiveness

Checks the database response time before each batch. If the database response is slow, then incrementally waits until the response is better. Useful when the database is expect to be umder high load.

--sleep=<milliseconds>

When set, the indexer will wait for this many milliseconds after each batch. Useful when the database is expect to be under high load.

--post-id=<post_id>

Used with the wp asp index item --post-id=123 command. Specifies which post ID should be reindexed.

--separate-process

When present, each batch is executed in a separate PHP process. Highly recommended for larger databases (10 000+ posts), where indexing takes a long time. Reduces memory usage greatly for large databases. On smaller databases has almost no effect.

Creating a new index

To create a new index run:

For larger databases it is recommended to use larger batches and process separation:

Continuing the existing index

To continue the indexing:

For larger databases it is recommended to use larger batches and process separation:

Re-indexing a specific post

To reindex a specific post (or post type) by it's id:

This will update the post in the index.

Emptying the index

To remove (delete) all items from the index table:

Get information from the index

To get the index table size and the indexed items count run:

Running the index commands as cron jobs

It is possible to execute all of the commands in a crontab as well.

circle-info

If you are not familar with cron jobs, please read this article firstarrow-up-right.

To add a server side cron command, you need to edit the server crontab:

Crontab command synopsis:

  • --skip-confirm flag ensures that no confirmation message is shown, otherwise the command will stuck

  • --path is very important, it must point to the wordpress installation path, otherwise the command will be executed in the home directory

For example, to create a new index every day at midnight assuming wordpress is installed in the "/var/www/public_html" directory:

Last updated