List Index tool
The ListIndexTool lists the indexes in your Lucenia cluster and returns, for each index, its health, status, index name, uuid, primary and replica counts, document counts, and store sizes. It returns the same information as the CAT Indices API in a comma-separated table.
Step 1: Register a flow agent that will run the ListIndexTool
A flow agent runs a sequence of tools in order and returns the last tool's output. To create a flow agent, send the following register agent request:
POST /_plugins/_ml/agents/_register
{
"name": "Test_Agent_For_ListIndex_tool",
"type": "flow",
"description": "this is a test agent for the ListIndexTool",
"tools": [
{
"type": "ListIndexTool",
"name": "DemoListIndexTool",
"parameters": {
"input": "${parameters.question}"
}
}
]
}
For parameter descriptions, see Register parameters.
Lucenia responds with an agent ID:
{
"agent_id": "9X7xWI0Bpc3sThaJdY9i"
}
Step 2: Run the agent
Run the agent by sending the following request. Leave indices empty (or omit it) to list all indexes in the cluster:
POST /_plugins/_ml/agents/9X7xWI0Bpc3sThaJdY9i/_execute
{
"parameters": {
"question": "How many indices do I have?"
}
}
Lucenia returns the index information in a comma-separated table:
{
"inference_results": [
{
"output": [
{
"name": "response",
"result": """health,status,index,uuid,pri,rep,docs.count,docs.deleted,store.size,pri.store.size
green,open,.plugins-ml-model-group,lHgGEgJhT_mpADyOZoXl2g,1,1,9,2,33.4kb,16.7kb
green,open,my_test_data,T4hwNs7CTJGIfw2QpCqQ_Q,1,1,6,0,91.7kb,45.8kb
green,open,.plugins-ml-agent,7X1IzoLuSGmIujOh9i5mmg,1,1,30,0,170.7kb,85.3kb
"""
}
]
}
]
}
Register parameters
The following table lists all tool parameters that are available when registering an agent.
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
indices | Array | Optional | A list of one or more index names for which to return information, for example ["index1", "index2"]. Default is an empty list, which lists all indexes in the cluster. |
local | Boolean | Optional | When true, retrieves information from the local node only instead of the cluster manager node (default is false). |
page_size | Integer | Optional | The number of indexes to retrieve per page. Default is 100. |
Execute parameters
The following table lists all tool parameters that are available when running the agent.
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
question | String | Optional | A natural language question describing the index information you want. |
indices | Array | Optional | A list of one or more index names for which to return information. Default is an empty list, which lists all indexes in the cluster. |