RESTful API to Manage Indexes - Documentation topics on: elasticsearch,managing site indexes with elastic search,restful api to manage indexes,.

RESTful API to Manage Indexes

You can use the dotCMS REST API to manage indexes, performing all the same operations that are documented in the Managing Site Indexes with Elastic Search documentation. Note: You can verify the results of your REST API calls by viewing index information in the dotCMS backend.

User Authentication

All of the following examples assume the server is running on localhost:8080, and the user has been authenticated on your dotCMS instance as a user with permissions to modify the indexes.

In all of the following example commands:

  • Replace localhost:8080 with the domain name and port of your dotCMS instance.
  • Provide actual values where optional values are indicated (in square brackets).
  • You can also authenticate users using standard dotCMS REST API authentication (passing user and password as parameters, or using cookie based sessions).

Download an Index

The following curl command downloads an index with name working_20130628092243:

curl --user -XGET http://localhost:8080/api/esindex/download/index/working_20130628092243 >

To download the current live or working index, pass live or working, respecitvely, as the index name.

curl --user -XGET http://localhost:8080/api/esindex/download/index/live >

Restore an Index

The following example restores an index which was previously downloaded.


  • The index to be restored must be sent in zip format.
  • Some browsers, such as Safari, may automatically extract the downloaded zip files, so you must make sure to send a zipped version of the downloaded index.

The URI parameter clear deletes all the documents in the index before restoring (completely overwriting the existing index with the index being restored). This parameter defaults to false.

curl --user -F  -XPUT http://localhost:8080/api/esindex/restore/index/working_20130705193521/clear/true

Create an Index




ParameterAccepted ValuesDescription
/live/[value]true, falseCreates a live (true) or working (false) index.
shardsIntegerSpecifies the number of shards for the new index.
indexName (String)If specified, sets the index name.
If not specified, a default index name will be generated.
/alias/[name]Alias Name (String)If specified, sets the index from an alias of the index.


The name of the new index in text/plain format.

Example 1:

The following curl command creates a new working index with 2 shards and a default index name:


curl --user -XPUT http://localhost:8080/api/esindex/create/live/false/shards/2



Example 2:

The following curl command creates a new live index with 2 shards and a custom index name:


curl --user -XPUT http://localhost:8080/api/esindex/create/live/true/shards/2/index/fandango



Clear an Index

Clears all contents out of the specified index (but does not delete the index).




curl --user -XPUT http://localhost:8080/api/esindex/clear/index/working_20130707223633

Delete an Index

Deletes the specified index.


curl --user -XDELETE http://localhost:8080/api/esindex/index/working_20130707223633

Activate an Index

When used on a content index, sets the specified index to the active index. When used on a sitesearch index, makes the specified index the default index.


curl --user -XPUT http://localhost:8080/api/esindex/activate/index/working_20130707233404

Deactivate an Index

curl --user -XPUT http://localhost:8080/api/esindex/deactivate/index/working_20130707233404

Update Replica

Duplicates the specified index. The number of copies of an index in a cluster is equal to the number of replicas plus one; so, for example, if there is 1 replica then there will be 2 copies of the index in the cluster.

curl --user -XPUT http://localhost:8080/api/esindex/updatereplica/index/working_20130707233404/replicas/1

Close an Index

Closes file descriptors and releases memory used to operate over the index. After this operation is performed, the index will not be available for queries until it is reopened with the open operation. This operation allows you to stop using an index without deleting it; however a closed index will still take up the full amount of drive space of a normal index.

curl --user -XPUT http://localhost:8080/api/esindex/close/index/working_20130707233404

Open an Index

Re-open an index which has been closed.

curl --user -XPUT http://localhost:8080/api/esindex/open/index/working_20130707233404

Get Active Index

Returns the name of the current live or working index.

The working index (note the “type” parameter)

Example: Get Current Working Index


curl --user -XGET http://localhost:8080/api/esindex/active/type/working



Example: Get Current Live Index


curl --user -XGET http://localhost:8080/api/esindex/active/type/live



Get Document Count

Returns the number of documents stored in the specified index.



curl --user -XGET http://localhost:8080/api/esindex/docscount/index/working_20130628092243



List Indices

Returns a list of all indices on the system. Uses json format, which can be easily parsed with the JSONTool.



curl --user -XGET http://localhost:8080/api/esindex/indexlist/