The Elasticsearch connector lets your AI agent act in each user's Elasticsearch account. Each user connects their own Elasticsearch API key once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 25 tools.
- Tools
- 25
- What they doRead · write · destructive
- 14 · 8 · 314 read8 write3 destructive
- Users sign in with
- API key
Setup
Install the SDK
Terminal window npm install @scalekit-sdk/node dotenvTerminal window pip install scalekit-sdk-python python-dotenvSet your credentials
Add your Scalekit credentials to your
.envfile. Find values in app.scalekit.com > Developers > API Credentials..env SCALEKIT_ENVIRONMENT_URL=<your-environment-url>SCALEKIT_CLIENT_ID=<your-client-id>SCALEKIT_CLIENT_SECRET=<your-client-secret>Create the Elasticsearch connection
In AgentKit > Connections, create an Elasticsearch connection. The name you give it is the
connection_nameyour code passes. See Configure connections.Authorize a user and make your first call
quickstart.mts import { ScalekitClient } from '@scalekit-sdk/node'import 'dotenv/config'import { createInterface } from 'node:readline/promises'const scalekit = new ScalekitClient(process.env.SCALEKIT_ENVIRONMENT_URL,process.env.SCALEKIT_CLIENT_ID,process.env.SCALEKIT_CLIENT_SECRET,)const actions = scalekit.actionsconst connector = 'elasticsearch'const identifier = 'user_123'// Generate an authorization link for the userconst { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })console.log('Authorize Elasticsearch:', link)const rl = createInterface({ input: process.stdin, output: process.stdout })await rl.question('Press Enter after authorizing...')rl.close()// Make your first callconst result = await actions.executeTool({connector,identifier,toolName: 'elasticsearch_aliases_list',toolInput: {},})console.log(result)Terminal window npx tsx quickstart.mtsquickstart.py import osfrom scalekit import ScalekitClientfrom dotenv import load_dotenvload_dotenv()scalekit_client = ScalekitClient(env_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),client_id=os.getenv("SCALEKIT_CLIENT_ID"),client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),)actions = scalekit_client.actionsconnection_name = "elasticsearch"identifier = "user_123"# Generate an authorization link for the userlink_response = actions.get_authorization_link(connection_name=connection_name,identifier=identifier,)print("Authorize Elasticsearch:", link_response.link)input("Press Enter after authorizing...")# Make your first callresult = actions.execute_tool(tool_input={},tool_name="elasticsearch_aliases_list",connection_name=connection_name,identifier=identifier,)print(result)Terminal window python quickstart.pyEach user opens the link once and enters their Elasticsearch credentials there. See Authorize a user for the full flow and statuses.
Tools
Pass the exact name toexecute_toolelasticsearch_aliases_listList index aliases in the cluster as JSON.Read-onlyList Aliases
List index aliases in the cluster as JSON. Returns one row per alias with alias, index, filter, routing and is_write_index. Use Update Aliases to add, move or remove aliases.
Inputs
hstring- Columns to return. Example: alias,index,is_write_index.
sstring- Columns to sort by. Example: alias.
elasticsearch_cluster_health_getGet the health of the Elasticsearch cluster.Read-onlyGet Cluster Health
Get the health of the Elasticsearch cluster. Returns status (green, yellow or red), number_of_nodes, active and unassigned shard counts and pending tasks. Use level=indices to get health per index.
Inputs
levelstring- Detail level: cluster (default), indices or shards. Example: indices.one of
clusterindicesshards timeoutstring- How long to wait when wait_for_status is set, as a time unit. Elasticsearch defaults to 30s. Example: 10s.
wait_for_statusstring- Wait until the cluster reaches at least this status, up to timeout: green, yellow or red. Example: yellow.one of
greenyellowred
elasticsearch_cluster_info_getGet basic information about the Elasticsearch cluster.Read-onlyGet Cluster Info
Get basic information about the Elasticsearch cluster. Returns the node name, cluster_name, cluster_uuid and version details (number, build flavor, Lucene version). Use this to test the connection and check the Elasticsearch version.
Inputs
This tool takes no inputs.
elasticsearch_countCount the documents matching a query in one or more indices.Read-onlyCount Documents
Count the documents matching a query in one or more indices. Returns count and _shards. Omit query to count every document.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
queryobject- Query DSL object selecting the documents to count. Example: {"match": {"title": "laptop"}}.
elasticsearch_document_getGet one document by index and ID.Read-onlyGet Document
Get one document by index and ID. Returns _index, _id, _version, found and the document in _source. Use Search for anything other than a lookup by ID.
Inputs
idstringrequired- Document ID. Example: sku-1001.
indexstringrequired- Name of a single index. Example: products.
routingstring- Custom routing value used when the document was indexed. Example: user-42.
source_includesstring- Comma-separated source fields to return. Example: title,price.
elasticsearch_documents_get_manyGet several documents from an index by ID in one request.Read-onlyGet Multiple Documents
Get several documents from an index by ID in one request. Returns docs, one entry per ID with found, _version and _source. Use this instead of repeated Get Document calls.
Inputs
idsarrayrequired- Document IDs to fetch. Example: ["sku-1001", "sku-1002"].
indexstringrequired- Name of a single index. Example: products.
source_includesstring- Comma-separated source fields to return. Example: title,price.
elasticsearch_esql_queryRun an ES|QL piped query, for example FROM products | WHERE price > 100 | STATS avg(price) BY brand.Read-onlyES|QL Query
Run an ES|QL piped query, for example FROM products | WHERE price > 100 | STATS avg(price) BY brand. Returns columns (name and type) and values as rows. Use this for analytics-style queries; use Search for full-text relevance search.
Inputs
querystringrequired- The ES|QL query. Example: FROM products | WHERE price > 100 | STATS avg_price = AVG(price) BY brand | LIMIT 10.
columnarboolean- Set true to return values column by column instead of row by row. Example: false.
filterobject- Query DSL filter applied before the ES|QL query. Example: {"range": {"@timestamp": {"gte": "now-1d"}}}.
paramsarray- Values for ? placeholders in the query, in order. Example: [100].
elasticsearch_field_capabilities_getGet the type and search or aggregation capability of fields across one or more indices.Read-onlyGet Field Capabilities
Get the type and search or aggregation capability of fields across one or more indices. Returns indices and fields, each field keyed by type with searchable and aggregatable flags. Use this to check whether a field can be sorted or aggregated on.
Inputs
fieldsstringrequired- Comma-separated field names; wildcards allowed. Example: title,price,*_at.
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
elasticsearch_index_getGet an index's aliases, mappings and settings.Read-onlyGet Index
Get an index's aliases, mappings and settings. Returns an object keyed by index name with aliases, mappings and settings. Use Get Index Mapping when you only need the field mappings.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
elasticsearch_index_mapping_getGet the field mappings of one or more indices.Read-onlyGet Index Mapping
Get the field mappings of one or more indices. Returns an object keyed by index name with mappings.properties describing each field's type. Use this before writing queries to learn field names and types.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
elasticsearch_index_settings_getGet the settings of one or more indices.Read-onlyGet Index Settings
Get the settings of one or more indices. Returns an object keyed by index name with settings such as number_of_shards, number_of_replicas, creation_date and uuid. Use Get Index for settings, mappings and aliases together.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
elasticsearch_indices_listList the indices in the cluster as JSON.Read-onlyList Indices
List the indices in the cluster as JSON. Returns one row per index with health, status, index name, uuid, primary and replica counts, docs.count, docs.deleted and store size. Use this to discover index names.
Inputs
expand_wildcardsstring- Which indices to include: open (default), closed, hidden, all or none, comma-separated. Example: all.
hstring- Columns to return, comma-separated. Example: index,health,docs.count,store.size.
healthstring- Only indices with this health: green, yellow or red. Example: yellow.one of
greenyellowred sstring- Columns to sort by, comma-separated, each optionally with :asc or :desc. Example: docs.count:desc.
elasticsearch_searchSearch one or more indices with the Query DSL, with sorting, paging, field filtering, highlighting and aggregations.Read-onlySearch
Search one or more indices with the Query DSL, with sorting, paging, field filtering, highlighting and aggregations. Returns took, hits.total, hits.hits (each with _id, _score and _source) and aggregations when requested. Use Count for counts only, or ES|QL Query for piped analytics queries.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
aggregationsobject- Aggregations to compute, keyed by name. Example: {"avg_price": {"avg": {"field": "price"}}}.
frominteger- Hits to skip, for paging (from + size is capped at 10,000 by default). Example: 20.
highlightobject- Highlighting settings. Example: {"fields": {"title": {}}}.
queryobject- Query DSL object selecting the documents to return. Example: {"match": {"title": "laptop"}}.
search_afterarray- Sort values of the last hit from the previous page, for deep paging with sort. Example: [899.0, "sku-1001"].
sizeinteger- Number of hits to return. Elasticsearch defaults to 10. Example: 20.
sortarray- Sort order, a list of fields or field objects. Example: [{"price": "asc"}, "_score"].
sourcearray- Source fields to return in each hit. Example: ["title", "price"].
track_total_hitsboolean- Set true to count all matching hits exactly instead of stopping at 10,000. Example: true.
elasticsearch_sql_queryRun an Elasticsearch SQL query and get rows back as JSON, with cursor paging.Read-onlySQL Query
Run an Elasticsearch SQL query and get rows back as JSON, with cursor paging. Returns columns, rows and a cursor when more rows remain. Pass the cursor alone (without query) to fetch the next page.
Inputs
cursorstring- Cursor from the previous response, to fetch the next page. Example: sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==.
fetch_sizeinteger- Rows per page. Elasticsearch defaults to 1000. Example: 100.
filterobject- Query DSL filter applied before the SQL query. Example: {"term": {"brand": "acme"}}.
querystring- SQL query. Required unless cursor is set. Example: SELECT brand, AVG(price) FROM products GROUP BY brand.
elasticsearch_aliases_updateAdd, remove or move index aliases in one atomic request.WriteUpdate Aliases
Add, remove or move index aliases in one atomic request. Returns acknowledged. Use an add and a remove action together to switch an alias between indices without downtime.
- Idempotent
Inputs
actionsarrayrequired- Alias actions, each an object with one key: add, remove or remove_index. add and remove take index and alias (plus optional filter, routing or is_write_index). Example: [{"remove": {"index": "products-v1", "alias": "products"}}, {"add": {"index": "products-v2", "alias": "products"}}].
elasticsearch_document_addAdd a document to an index with an ID generated by Elasticsearch.WriteAdd Document
Add a document to an index with an ID generated by Elasticsearch. Returns _index, the new _id, _version and result created. Use Index Document when you want to choose the ID.
Inputs
documentobjectrequired- The document to store as JSON. Example: {"title": "Laptop", "price": 999.0}.
indexstringrequired- Name of a single index. Example: products.
pipelinestring- Ingest pipeline to run on the document. Example: enrich-products.
refreshstring- When the change becomes visible to search: true refreshes now, wait_for waits for the next refresh, false (default) does nothing. Example: wait_for.one of
truefalsewait_for routingstring- Custom routing value used when the document was indexed. Example: user-42.
elasticsearch_document_indexCreate or fully replace the document with a given ID in an index.WriteIndex Document
Create or fully replace the document with a given ID in an index. Returns _index, _id, _version and result (created or updated). Use Update Document to change only some fields, or op_type=create to fail if the ID exists.
- Idempotent
Inputs
documentobjectrequired- The full document to store as JSON. Example: {"title": "Laptop", "price": 999.0}.
idstringrequired- Document ID. Example: sku-1001.
indexstringrequired- Name of a single index. Example: products.
op_typestring- index (default) creates or replaces; create fails if the ID already exists. Example: create.one of
indexcreate pipelinestring- Ingest pipeline to run on the document. Example: enrich-products.
refreshstring- When the change becomes visible to search: true refreshes now, wait_for waits for the next refresh, false (default) does nothing. Example: wait_for.one of
truefalsewait_for routingstring- Custom routing value used when the document was indexed. Example: user-42.
elasticsearch_document_updatePartially update a document by merging fields into it, or change it with a script, optionally upserting.WriteUpdate Document
Partially update a document by merging fields into it, or change it with a script, optionally upserting. Returns _index, _id, _version and result (updated, noop or created). Pass doc for a partial merge or script for computed changes, not both.
Inputs
idstringrequired- Document ID. Example: sku-1001.
indexstringrequired- Name of a single index. Example: products.
docobject- Fields to merge into the existing document. Example: {"price": 899.0}.
doc_as_upsertboolean- Set true to create the document from doc if it does not exist. Example: true.
refreshstring- When the change becomes visible to search: true refreshes now, wait_for waits for the next refresh, false (default) does nothing. Example: wait_for.one of
truefalsewait_for retry_on_conflictinteger- How many times to retry on a version conflict. Example: 3.
routingstring- Custom routing value used when the document was indexed. Example: user-42.
scriptobject- Painless script with source and optional params. Example: {"source": "ctx._source.stock -= params.n", "params": {"n": 1}}.
upsertobject- Document to insert when it does not exist (used with script). Example: {"stock": 10}.
elasticsearch_index_createCreate a new Elasticsearch index with optional settings, field mappings and aliases.WriteCreate Index
Create a new Elasticsearch index with optional settings, field mappings and aliases. Returns acknowledged, shards_acknowledged and the index name. Index names must be lowercase. Fails if the index exists.
Inputs
indexstringrequired- Name of a single index. Example: products.
aliasesobject- Aliases to create with the index, keyed by alias name. Example: {"products": {}}.
mappingsobject- Field mappings, usually a properties object mapping field names to types. Example: {"properties": {"title": {"type": "text"}, "price": {"type": "float"}}}.
settingsobject- Index settings such as number_of_shards and number_of_replicas. Example: {"number_of_shards": 1, "number_of_replicas": 1}.
elasticsearch_index_mapping_updateAdd new fields to an index's mapping or change mapping parameters that can be updated.WriteUpdate Index Mapping
Add new fields to an index's mapping or change mapping parameters that can be updated. Returns acknowledged. Existing field types cannot be changed; reindex into a new index for that.
- Idempotent
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
propertiesobjectrequired- New or updated field mappings keyed by field name. Example: {"in_stock": {"type": "boolean"}}.
dynamicstring- How unmapped fields in new documents are handled: true, false, strict or runtime. Example: strict.one of
truefalsestrictruntime
elasticsearch_index_refreshRefresh one or more indices so recent writes become visible to search.WriteRefresh Index
Refresh one or more indices so recent writes become visible to search. Returns _shards with total, successful and failed counts. Use this after writes when search must see them immediately; avoid calling it in tight loops.
- Idempotent
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
elasticsearch_update_by_queryUpdate every document matching a query with a Painless script.WriteUpdate by Query
Update every document matching a query with a Painless script. Returns took, total, updated, batches, version_conflicts and failures. Run Count with the same query first to check how many documents match.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
scriptobjectrequired- Painless script applied to each matching document. Example: {"source": "ctx._source.on_sale = true"}.
conflictsstring- What to do on version conflicts: abort (default) or proceed. Example: proceed.one of
abortproceed max_docsinteger- Maximum number of documents to update. Example: 1000.
queryobject- Query DSL object selecting the documents to update. Example: {"match": {"title": "laptop"}}.
refreshboolean- Set true to refresh the affected shards after the request. Example: true.
elasticsearch_delete_by_queryDelete every document matching a query in one or more indices.DestructiveDelete by Query
Delete every document matching a query in one or more indices. Returns took, total, deleted, batches, version_conflicts and failures. This cannot be undone. Run Count with the same query first to check how many documents match.
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
queryobjectrequired- Query DSL object selecting the documents to delete. Example: {"match": {"title": "laptop"}}.
conflictsstring- What to do on version conflicts: abort (default) or proceed. Example: proceed.one of
abortproceed max_docsinteger- Maximum number of documents to delete. Example: 1000.
refreshboolean- Set true to refresh the affected shards after the request. Example: true.
elasticsearch_document_deleteDelete one document by index and ID.DestructiveDelete Document
Delete one document by index and ID. Returns _index, _id, _version and result (deleted or not_found). Use Delete by Query to delete many documents.
- Idempotent
Inputs
idstringrequired- Document ID. Example: sku-1001.
indexstringrequired- Name of a single index. Example: products.
refreshstring- When the change becomes visible to search: true refreshes now, wait_for waits for the next refresh, false (default) does nothing. Example: wait_for.one of
truefalsewait_for routingstring- Custom routing value used when the document was indexed. Example: user-42.
elasticsearch_index_deleteDelete one or more Elasticsearch indices and all their documents.DestructiveDelete Index
Delete one or more Elasticsearch indices and all their documents. Returns acknowledged. This cannot be undone. Wildcards may be refused by the cluster's action.destructive_requires_name setting.
- Idempotent
Inputs
indexstringrequired- Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
ignore_unavailableboolean- Set true to not fail when an index is missing. Example: true.
No tools match.