Admin Maintenance API

Overview

The Maintenance API runs the operations of the Maintenance screen with an access token. It starts a reindex, reloads the document index, deletes the crawler indices, rebuilds the configuration indices, downloads diagnostic information, and returns the running state of these operations.

Authentication

Access to this API requires authentication using an access token. Specify the access token in the request header.

Authorization: Bearer <access_token>

The access token must be granted the Admin API permission (Radmin-api by default). For details on how to obtain an access token and about permissions, see Admin API Overview.

Base URL

/api/admin/maintenance

Endpoint List

Method Path Description
GET / Get Operation Status
PUT /reindex Start Reindexing
PUT /reload Reload the Document Index
DELETE /crawler Delete the Crawler Indices
PUT /rebuild Rebuild Configuration Indices
GET /diagnostic Download Diagnostic Information

Reindexing, reloading, deleting and rebuilding run asynchronously. A response with status 0 means that the operation was accepted, not that it has finished or succeeded. A request is rejected while the same operation is running.

Get Operation Status

Request

GET /api/admin/maintenance

Response

{
  "response": {
    "version": "15.10",
    "status": 0,
    "operations": [
      {"name": "reindex", "running": false},
      {"name": "reload_doc_index", "running": true, "hostname": "fess-node1", "created_time": 1796431977058},
      {"name": "clear_crawler_index", "running": false},
      {"name": "reindex_config", "running": false}
    ]
  }
}
Field Description
operations[].name Operation name: reindex (/reindex), reload_doc_index (/reload), clear_crawler_index (/crawler) or reindex_config (/rebuild)
operations[].running true while the operation is running
operations[].hostname Host name running the operation (only while running)
operations[].created_time Time the operation started, in epoch milliseconds (only while running)

Note

Note the following when you read running.

  • false does not mean success. It is also false after a failed operation. Failures are written to the server log.

  • A reindex with replace_aliases set to false clears the running state as soon as the copy has been submitted to the search engine, so it shows false while documents are still being copied.

  • The running state expires after coordinator.operation.ttl (7200000 milliseconds, or 2 hours, by default) and is not extended. An operation that takes longer shows false while still running, and the same operation is accepted again.

  • It is also false when the state cannot be read from the search engine.

Start Reindexing

Copies the documents of the current document index into a new index. All properties are optional, and the request can be sent without a body.

Request

PUT /api/admin/maintenance/reindex
{
  "replace_aliases": true,
  "reset_dictionaries": false,
  "number_of_shards_for_doc": "5",
  "auto_expand_replicas_for_doc": "0-1"
}
Field Type Default Description
replace_aliases boolean true Move the fess.search and fess.update aliases to the new index after the copy has finished
reset_dictionaries boolean false Reset the dictionary settings. It has no effect with a search engine without the CodeLibs plugins
number_of_shards_for_doc string Value of index.number_of_shards Number of shards of the new index (up to 10 characters). The default is used if empty
auto_expand_replicas_for_doc string Value of index.auto_expand_replicas index.auto_expand_replicas of the new index (up to 10 characters). The default is used if empty

HTTP status 400 is returned when the new index cannot be created, for example because the number of shards is invalid.

Response

{
  "response": {
    "version": "15.10",
    "status": 0
  }
}

Reload the Document Index

Writes the stored dictionaries to the files of the search engine, then closes and reopens the index that the fess.update alias points to. The index cannot be searched while it is closed. The request has no body.

Request

PUT /api/admin/maintenance/reload

Note

This is not available with a search engine without the CodeLibs plugins (search_engine.type set to vanilla, aws or cloud); HTTP status 404 is returned.

Delete the Crawler Indices

Deletes the crawler indices (fess_crawler.queue, fess_crawler.data and fess_crawler.filter). The request has no body.

Request

DELETE /api/admin/maintenance/crawler

Warning

Do not run this while a crawler is running.

Rebuild Configuration Indices

Recreates the configuration indices with the latest mappings. The stored data is carried over.

Request

PUT /api/admin/maintenance/rebuild
{
  "rebuild_config_index": true,
  "rebuild_user_index": false,
  "rebuild_log_index": false,
  "load_bulk_data": false
}
Field Type Default Description
rebuild_config_index boolean false Rebuild the configuration indices (fess_config)
rebuild_user_index boolean false Rebuild the user indices (fess_user)
rebuild_log_index boolean false Rebuild the log indices (fess_log)
load_bulk_data boolean false Load the default data during the rebuild. Existing data is not overwritten

Set at least one of rebuild_config_index, rebuild_user_index and rebuild_log_index to true. Unlike the administration screen, no target is selected by default.

Warning

Back up your configuration before you run this.

rebuild_config_index also deletes and recreates the indices that hold the access tokens and the running state (fess_config.access_token and fess_config.coordinator). While that happens, API authentication may fail and running may show false. In a test with little data, requests sent about once a second did not fail.

Download Diagnostic Information

Returns the same diagnostic zip file as the log download on the maintenance screen. For the files it contains, see Maintenance.

Request

GET /api/admin/maintenance/diagnostic

Response

The response is an application/octet-stream file named log<yyyyMMddHHmm>.zip. It does not contain Admin API access tokens, and secret values in the configuration files are replaced with XXXXXXXX.

Warning

The log files and fess_basic_config.bulk are not masked. Check the contents before you send the zip file to others.

Error Responses

HTTP status status Cause
400 1 The same operation is already running
400 1 The destination index of the reindex cannot be created
400 1 No rebuild target is specified
400 1 A property value is invalid, such as a string longer than 10 characters
401 3 The access token is missing or invalid, or lacks the permission
404 9 Reload with a search engine without the CodeLibs plugins
{
  "response": {
    "version": "15.10",
    "status": 1,
    "message": "The operation is already running on fess-node1."
  }
}

A string other than true or false in a boolean property is not rejected; it is treated as false.

For details of the status values and HTTP status codes, see Admin API Overview.

Usage Examples

Get Operation Status

curl -X GET "http://localhost:8080/api/admin/maintenance" \
     -H "Authorization: Bearer YOUR_TOKEN"

Start Reindexing

curl -X PUT "http://localhost:8080/api/admin/maintenance/reindex" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"replace_aliases": true}'

Reload the Document Index

curl -X PUT "http://localhost:8080/api/admin/maintenance/reload" \
     -H "Authorization: Bearer YOUR_TOKEN"

Delete the Crawler Indices

curl -X DELETE "http://localhost:8080/api/admin/maintenance/crawler" \
     -H "Authorization: Bearer YOUR_TOKEN"

Rebuild Configuration Indices

curl -X PUT "http://localhost:8080/api/admin/maintenance/rebuild" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"rebuild_config_index": true}'

Download Diagnostic Information

curl -X GET "http://localhost:8080/api/admin/maintenance/diagnostic" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -o diagnostic.zip

References