All commands support these global flags:
--config- Specify config file location (default:~/.searchctl/config.yaml)--context- Override current context--output, -o- Output format:table(default),json,yaml,wide--verbose, -v- Enable verbose output--dry-run- Show what would be done without executing
List and display resources from the cluster.
searchctl get indices [INDEX_PATTERN] [flags]Aliases: index, idx
Examples:
# List all indices
searchctl get indices
# List indices matching pattern
searchctl get indices logs-*
# Output as JSON
searchctl get indices -o jsonsearchctl get nodes [flags]Aliases: node, no
Examples:
# List all nodes
searchctl get nodes
# List nodes with wide output
searchctl get nodes -o widesearchctl get datastreams [PATTERN] [flags]Aliases: datastream, ds
Examples:
# List all data streams
searchctl get datastreams
# List data streams matching pattern
searchctl get datastreams logs-*
# Output as JSON
searchctl get datastreams -o jsonShow detailed information about specific resources.
searchctl describe index INDEX_NAME [flags]Aliases: idx
Examples:
# Describe specific index
searchctl describe index my-logs-index
# Output as YAML
searchctl describe index my-index -o yamlsearchctl describe lifecycle-policy POLICY_NAME [flags]Aliases: lifecyclepolicy, ilm, ism, lp, lifecycle
Flags:
--show-body- Include full policy body when using table output
Examples:
# Describe lifecycle policy (table)
searchctl describe lifecycle-policy basic-log-rotation
# As YAML (full object)
searchctl describe lifecycle-policy basic-log-rotation -o yamlsearchctl describe index-template TEMPLATE_NAME [flags]Aliases: indextemplate, template, it, idx-template
Flags:
--show-body- Include full template body when using table output
Examples:
# Describe index template
searchctl describe index-template logs-template
# As JSON (full object)
searchctl describe index-template logs-template -o jsonsearchctl describe component-template NAME [flags]Aliases: componenttemplate, ct
Flags:
--show-body- Include full template body when using table output
Examples:
searchctl describe component-template base-settingssearchctl describe datastream NAME [flags]Aliases: datastreams, ds
Examples:
searchctl describe datastream logs-nginx
searchctl describe datastream logs-nginx -o yamlsearchctl describe node NODE_ID [flags]Aliases: no
Examples:
searchctl describe node node-1Create new resources in the cluster.
searchctl create index INDEX_NAME [flags]Aliases: idx
Examples:
# Create new index
searchctl create index new-logs
# Dry run creation
searchctl create index test-index --dry-runsearchctl create datastream DATA_STREAM_NAME [flags]Aliases: ds
Examples:
# Create new data stream
searchctl create datastream logs-nginx
# Dry run creation
searchctl create datastream logs-test --dry-runDelete resources from the cluster.
searchctl delete index INDEX_NAME_OR_PATTERN [flags]Aliases: idx
Flags:
-y, --yes- Automatically confirm deletion without prompting
Examples:
# Delete specific index (with confirmation prompt)
searchctl delete index old-logs
# Delete multiple indices with wildcard (with confirmation prompt)
searchctl delete index logs-*
# Delete indices matching pattern without confirmation
searchctl delete index test-index-* -y
# Dry run deletion
searchctl delete index temp-index --dry-run
# Dry run with wildcard
searchctl delete index logs-2024-* --dry-runsearchctl delete datastream DATA_STREAM_NAME_OR_PATTERN [flags]Aliases: ds
Flags:
-y, --yes- Automatically confirm deletion without prompting
Examples:
# Delete specific data stream and all backing indices (with confirmation prompt)
searchctl delete datastream old-logs
# Delete multiple data streams with wildcard (with confirmation prompt)
searchctl delete datastream logs-*
# Delete data streams matching pattern without confirmation
searchctl delete datastream metrics-* -y
# Dry run deletion
searchctl delete datastream temp-stream --dry-run
# Dry run with wildcard
searchctl delete datastream logs-2024-* --dry-runApply configurations from files.
searchctl apply -f FILE [flags]Flags:
-f, --filename- Configuration file to apply (required)
Examples:
# Apply index template
searchctl apply -f index-template.yaml
# Dry run apply
searchctl apply -f config.yaml --dry-runExport (clone) and import cluster configuration.
searchctl clone export [flags]Flags:
-d, --dir- Output directory (required)--types- Comma-separated list of resource types to export:index-templates,component-templates,lifecycle-policies,ingest-pipelines,cluster-settings--names- Optional names/patterns to filter (comma-separated). Empty exports all--include-system- Include system resources (names starting with.)
Examples:
# Export everything as YAML
searchctl clone export --dir /backup -o yaml
# Export only templates and ILM/ISM as JSON
searchctl clone export --types index-templates,component-templates,lifecycle-policies --dir /backup -o json
# Export only matching names/patterns
searchctl clone export --types index-templates --names logs-*,metrics-* --dir /backup -o yamlsearchctl clone import [flags]Import resources by scanning subdirectories in the given directory. Import order is component-templates → index-templates → lifecycle-policies → ingest-pipelines → cluster-settings.
Flags:
-d, --dir- Input directory (required)--types- Comma-separated list of resource types to import--dry-run- Show planned operations without applying--continue-on-error- Continue processing other files on errors
Examples:
# Import everything found in directory
searchctl clone import --dir /backup
# Dry run import of ILM and pipelines
searchctl clone import --types lifecycle-policies,ingest-pipelines --dir /backup --dry-runRollover data streams to create new backing indices.
searchctl rollover datastream DATA_STREAM_NAME [flags]Aliases: ds
Flags:
--max-age- Maximum age before rollover (e.g., 30d, 1h)--max-docs- Maximum number of documents before rollover--max-size- Maximum index size before rollover (e.g., 50gb, 5gb)--max-primary-shard-size- Maximum primary shard size before rollover (e.g., 50gb)--max-primary-shard-docs- Maximum number of documents in primary shard before rollover--lazy- Only mark data stream for rollover at next write (data streams only)-f, --conditions-file- file containing rollover conditions (JSON or YAML)
Examples:
# Rollover based on age and document count
searchctl rollover datastream logs-nginx --max-age 7d --max-docs 1000000
# Rollover based on size
searchctl rollover datastream logs-app --max-size 50gb
# Rollover based on primary shard docs
searchctl rollover datastream logs-metrics --max-primary-shard-docs 500000
# Lazy rollover (mark for rollover at next write)
searchctl rollover datastream logs-system --lazy --max-age 1d
# Rollover using conditions file (JSON or YAML)
searchctl rollover datastream logs-system -f examples/rollover-conditions.json
searchctl rollover datastream logs-system -f examples/rollover-conditions.yaml
# Dry run rollover
searchctl rollover datastream logs-test --dry-run --max-age 1d
# Output as JSON
searchctl rollover datastream logs-metrics --max-docs 500000 -o jsonsearchctl cluster health [flags]Display cluster health status including node counts, shard distribution, and overall status.
Examples:
# Show cluster health
searchctl cluster health
# Health as JSON
searchctl cluster health -o jsonsearchctl cluster info [flags]Display general cluster information including version and cluster details.
Examples:
# Show cluster info
searchctl cluster info
# Info as YAML
searchctl cluster info -o yamlsearchctl config view [flags]Display the current configuration including contexts, clusters, and users.
Examples:
# View current config
searchctl config view
# View config as JSON
searchctl config view -o jsonsearchctl config use-context CONTEXT_NAME [flags]Switch to a different context for subsequent operations.
Examples:
# Switch to production context
searchctl config use-context production
# Switch to development context
searchctl config use-context developmentHuman-readable tabular format with aligned columns.
Machine-readable JSON format suitable for scripting and automation.
YAML format useful for configuration and human-readable structured data.
Extended table format with additional columns and details.
0- Success1- General error2- Configuration error3- Connection error4- Resource not found
During testing, we discovered that both Elasticsearch and OpenSearch have security restrictions on wildcard deletion:
- Setting:
action.destructive_requires_name(defaults totrue) - Error: "Wildcard expressions or all indices are not allowed"
- Documentation: "When set to
true, you must specify the index name to delete an index. It is not possible to delete all indices with_allor use wildcards."
- Similar restrictions: Also inherits the
action.destructive_requires_namesetting - Default behavior: Same as Elasticsearch - prevents wildcard deletion by default
Instead of requiring cluster administrators to modify security settings, we implemented client-side wildcard expansion:
- Pattern Detection: Detect wildcard patterns (containing
*) - List Matching Resources: Use GET APIs to list all indices/datastreams
- Filter Matches: Apply prefix matching for patterns ending with
* - Confirm Actions: Show user exactly what will be deleted
- Individual Deletion: Delete each resource one by one
- ✅ Works with default cluster security settings
- ✅ No special permissions required
- ✅ Clear visibility of what will be deleted
- ✅ Safe confirmation prompts with -y bypass
- ✅ Maintains backwards compatibility
All wildcard deletion features are working correctly:
- Single index/datastream deletion with confirmation
- Wildcard pattern detection and expansion
- Interactive confirmation prompts
- -y flag bypass for automation
- Error handling for non-existent patterns