Index Mapping tool

Introduced 2.12

This is an experimental feature and is not recommended for use in a production environment. For updates on the progress of the feature or if you want to leave feedback, see the associated GitHub issue.

The IndexMappingTool retrieves mapping and setting information for indexes in your cluster.

Step 1: Register a flow agent that will run the IndexMappingTool

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:

  1. POST /_plugins/_ml/agents/_register
  2. {
  3. "name": "Test_Agent_For_IndexMapping_tool",
  4. "type": "flow",
  5. "description": "this is a test agent for the IndexMappingTool",
  6. "tools": [
  7. {
  8. "type": "IndexMappingTool",
  9. "name": "DemoIndexMappingTool",
  10. "parameters": {
  11. "index": "${parameters.index}",
  12. "input": "${parameters.question}"
  13. }
  14. }
  15. ]
  16. }

copy

For parameter descriptions, see Register parameters.

OpenSearch responds with an agent ID:

  1. {
  2. "agent_id": "9X7xWI0Bpc3sThaJdY9i"
  3. }

Step 2: Run the agent

Before you run the agent, make sure that you add the sample OpenSearch Dashboards Sample eCommerce orders dataset. To learn more, see Adding sample data.

Then, run the agent by sending the following request and providing the index name and the question:

  1. POST /_plugins/_ml/agents/9X7xWI0Bpc3sThaJdY9i/_execute
  2. {
  3. "parameters": {
  4. "index": [ "sample-ecommerce" ],
  5. "question": "What fields are in the sample-ecommerce index?"
  6. }
  7. }

copy

OpenSearch returns the mappings and settings for the specified index:

  1. {
  2. "inference_results": [
  3. {
  4. "output": [
  5. {
  6. "name": "response",
  7. "result": """index: sample-ecommerce
  8. mappings:
  9. properties={items_purchased_failure={type=integer}, items_purchased_success={type=integer}, order_id={type=integer}, timestamp={type=date}, total_revenue_usd={type=integer}}
  10. settings:
  11. index.creation_date=1706752839713
  12. index.number_of_replicas=1
  13. index.number_of_shards=1
  14. index.provided_name=sample-ecommerce
  15. index.replication.type=DOCUMENT
  16. index.uuid=UPYOQcAfRGqFAlSxcZlRjw
  17. index.version.created=137217827
  18. """
  19. }
  20. ]
  21. }
  22. ]
  23. }

Register parameters

The following table lists all tool parameters that are available when registering an agent.

ParameterTypeRequired/OptionalDescription
inputStringRequiredThe user input used to return index information.
indexArrayRequiredA comma-delimited list of one or more indexes for which to obtain mapping and setting information. Default is an empty list, which means all indexes.
localBooleanOptionalWhether to return information from the local node only instead of the cluster manager node (default is false).

Execute parameters

The following table lists all tool parameters that are available when running the agent.

ParameterTypeRequired/OptionalDescription
questionStringRequiredThe natural language question to send to the LLM.
indexArrayOptionalA comma-delimited list of one or more indexes for which to obtain mapping and setting information. Default is an empty list, which means all indexes.