The CLI index command
The Sitecore indexing plugin includes an index command. This command automates indexing operations. To install the indexing plugin, run the following code:
Usage
You can use the command as follows:
Subcommands
You can use the following subcommands:
list- provides the list of available indexes from the environment.schema-populate- populates the managed schema.rebuild- rebuilds all the indexes.statistic- shows statistics of all the indexes.
All the subcommands require elevated permissions.
The list subcommand
The list subcommand provides the list of available indexes from the environment.
You can use the following options with the list subcommand:
| Option | Required | Description |
|---|---|---|
| -n, --environment-name | Optional | The Sitecore environment to use. Default: default. |
| -c, --config | Optional | Path to root sitecore.config directory (default: cwd). |
| -v, --verbose | Optional | Report additional diagnostic and performance data. |
| -t, --trace | Optional | Report additional diagnostic and performance data. |
| -?, -h, --help | Optional | Help for the command. |
For example:
The output of the command shows available indexes:
The schema-populate subcommand
The schema-populate subcommand populates the managed schema.
You can use the following options with the schema-populate subcommand:
| Option | Required | Description |
|---|---|---|
| -i, --indexes | Optional | Populate the schema for specified indexes. |
| -n, --environment-name | Optional | The Sitecore environment to use. Default: default. |
| -c, --config | Optional | Path to root sitecore.config directory (default: cwd). |
| -v, --verbose | Optional | Report additional diagnostic and performance data. |
| -t, --trace | Optional | Report additional diagnostic and performance data. |
| -?, -h, --help | Optional | Help for the command. |
You can use the command to populate specific indexes or all indexes.
For example, to populate a single index, you specify the name of the index using the -i option:
When the process finishes, it shows the result:
Running the command without specifying any index populates all the indexes in the managed schema. For example:
When the process completes, it displays the populated indexes:
The rebuild subcommand
The rebuild subcommand rebuilds all the indexes.
You can use the following options with the rebuild subcommand:
| Option | Required | Description |
|---|---|---|
| -i, --indexes | Optional | Rebuild the specified indexes. |
| -n, --environment-name | Optional | The Sitecore environment to use. Default: default. |
| -c, --config | Optional | Path to root sitecore.config directory (default: cwd). |
| -v, --verbose | Optional | Report additional diagnostic and performance data. |
| -t, --trace | Optional | Report additional diagnostic and performance data. |
| -?, -h, --help | Optional | Help for the command. |
You can use the command to rebuild specific indexes or all indexes.
For example, to rebuild a single index, you specify the name of the index using the -i option:
When the process finishes, it shows the result:
Running the command without specifying any index rebuilds all the indexes in the managed schema. For example:
When the process finishes, it displays the rebuilt indexes and the number of processed units:
The statistic subcommand
The statistic subcommand shows statistics of all the indexes.
You can use the following options with the statistic subcommand:
| Option | Required | Description |
|---|---|---|
| -n, --environment-name | Optional | The Sitecore environment to use. Default: default. |
| -c, --config | Optional | Path to root sitecore.config directory (default: cwd). |
| -t, --trace | Optional | Report additional diagnostic and performance data. |
| -?, -h, --help | Optional | Help for the command. |
For example, running the command:
displays the following information about available indexes: