# Index Table CLI

{% embed url="<https://youtu.be/XQmrTlvQcTk>" %}
Index Table CLI commands in action
{% endembed %}

#### Command synopsis

<pre><code><strong>wp asp index &#x3C;new|continue|delete|item|info> [--batch=&#x3C;batch>]
</strong>  [--skip-confirm] [--post_id=&#x3C;post_id>] [--check-responsiveness]
  [--sleep=&#x3C;milliseconds>] [--separate-process]
</code></pre>

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

<pre><code><strong>wp help asp index
</strong></code></pre>

#### Command flags

<table><thead><tr><th width="212">Flag</th><th>Description</th></tr></thead><tbody><tr><td><em><strong>--skip-confirm</strong></em></td><td>Skips the confirmation dialog when creating a new index or when deleting it.</td></tr><tr><td><em><strong>--batch=&#x3C;batch></strong></em></td><td>Number of posts (items) to index within an iteration step. Defaults to the number set on the plugin back-end.</td></tr><tr><td>--check-responsiveness</td><td>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.</td></tr><tr><td>--sleep=&#x3C;milliseconds></td><td>When set, the indexer will wait for this many milliseconds after each batch. Useful when the database is expect to be under high load.</td></tr><tr><td>--post-id=&#x3C;post_id></td><td>Used with the <code>wp asp index item --post-id=123</code> command. Specifies which post ID should be reindexed.</td></tr><tr><td>--separate-process</td><td>When present, each batch is executed in a separate PHP process. Highly recommended <strong>for larger databases</strong> (10 000+ posts), where indexing takes a long time. Reduces memory usage greatly for large databases.<br>On smaller databases has almost no effect.</td></tr></tbody></table>

#### Creating a new index

To create a new index run:

```
wp asp index new
```

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

```
wp asp index new --batch=200 --separate-process
```

#### Continuing the existing index

To continue the indexing:

```
wp asp index continue
```

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

```
wp asp index continue --batch=200 --separate-process
```

#### Re-indexing a specific post

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

```
wp asp index item --post-id=123
```

This will update the post in the index.

#### Emptying the index

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

```
wp asp index delete
```

#### Get information from the index

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

```
wp asp index info
```

#### Running the index commands as cron jobs

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

{% hint style="info" %}
If you are not familar with cron jobs, please read [this article first](https://www.geeksforgeeks.org/linux-unix/crontab-in-linux-with-examples/).
{% endhint %}

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

```
crontab -e
```

Crontab command synopsis:

```
* * * * * wp asp index <command> --skip-confirm --path=<path to wp>
```

* ***--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:

```
0 0 * * * wp asp index new --skip-confirm --path=/var/www/public_html
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.ajaxsearchpro.com/api/wp-cli-commands/index-table-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
