RESTful API to Manage Site Search Indexes - Documentation topics on: enterprise only,restful,restful api to manage indexes,.

RESTful API to Manage Site Search Indexes

The following documentation describes how to use CURL from the command line to manage indexes in the same ways as described in the Enterprise Site Search documentation.

In all of the following command examples, replace "localhost:8080" with the domain name/port of your dotCMS instance and provide an actual values where "YOURINDEXNAME", "YOURINDEX", "YOURPATH", or "DESIRED_REPLICAS_NUMBER" are mentioned.

On the dotCMS backend, click the refresh button on the Indices tab of Site Search to see the CURL command changes to indexes instead of refreshing your browser.

CREATE A NEW INDEX

The following command will create an new index - by default it will be named sitesearch_[timestamp]:

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/createSiteSearchIndex/shards/2

To provide an index alias:

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/createSiteSearchIndex/shards/2/alias/YOURINDEXALIAS

This will create a site search index with a specific alias

DOWNLOAD AN INDEX

The index is downloaded as a json zipped file.

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/downloadIndex/indexName/YOURINDEXNAME/ > INDEXNAME.zip
curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/downloadIndex/indexAlias/YOURINDEXALIAS/ > INDEXALIAS.zip

RESTORE AN INDEX

If aliasToRestore is specified then the restore goes to the associated index

curl -F aliasToRestore=torestore -F clearBeforeRestore=true -F uploadedfiles[]=@sitesearch_20120611161645.zip http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/restoreIndex

If no indexToRestore or aliasToRestore is specified then the restore in done over the default index

curl -F uploadedfiles[]=@sitesearch_20120611161645.zip http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/restoreIndex

It is important to note:  the "Restore an Index" curl command happens asynchronously, and will return once the index is uploaded but before the index is restored into ElasticSearch.  To see the progress of the index being restored, refresh the index listing screen.

CLEAN AN INDEX

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/clearIndex/indexName/YOURINDEXNAME

ACTIVATE INDEX

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/activateIndex/indexName/YOURINDEXNAME

DEACTIVATE INDEX

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/deactivateIndex/indexName/YOURINDEXNAME

LIST ALL NON ACTIVE INDICES

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/getNotActiveIndexNames

DELETE INDEX

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/deleteIndex/indexName/YOURINDEXNAME

GET INDEX NAME

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/getIndexName/indexAlias/YOURINDEXALIAS

UPDATE REPLICAS

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/updateReplicas/indexName/YOURINDEXNAME/replicas/DESIRED_REPLICAS_NUMBER

DELETE SEARCH JOB

curl http://localhost:8080/DotAjaxDirector/com.dotmarketing.sitesearch.ajax.SiteSearchAjaxAction/u/admin@dotcms.com/p/admin/cmd/deleteJob/taskName/YOURTASKNAME