devouted/elastic-index-manager

About

Maintainers

Package info

github.com/devouted/elastic-index-manager

pkg:composer/devouted/elastic-index-manager

Statistics

Installs: 855

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.2 2026-03-30 08:29 UTC

This package is auto-updated.

Last update: 2026-03-30 08:31:23 UTC


README

A Symfony console tool for managing Elasticsearch indexes interactively.

Requirements

  • PHP 8.2+
  • Symfony 7.3+
  • Elasticsearch PHP client 8.x

Installation

composer require devouted/elastic-index-manager

Configuration

Register the command in your services.yaml:

Devouted\ElasticIndexManager\Command\ElasticIndexManagerCommand:
    tags: ['console.command']

The command automatically discovers any service returning an Elastic\Elasticsearch\Client or Elastic\Elasticsearch\ClientBuilder instance. Example service definition:

elasticsearch.client.default:
    public: true
    class: Elastic\Elasticsearch\ClientBuilder
    factory: [ 'Elastic\Elasticsearch\ClientBuilder', 'create' ]
    calls:
        - [ setHosts, [ [ '%env(ELASTICSEARCH_TRANSPORT)%://%env(ELASTICSEARCH_HOST)%:%env(ELASTICSEARCH_PORT)%' ] ] ]

Usage

bin/console elasticsearch:index:manage

Connection selection

Choose which Elasticsearch connection to use from discovered services.

image

Index management

Once connected, you get an interactive table of all indexes with a summary footer showing totals for document counts and storage sizes.

image2

Available actions

Action Description
Change Elastic Client Switch to a different ES connection
Filter for empty indexes Show only indexes with docs.count = 0
Filter by index pattern Filter indexes by name pattern
Reset filter Remove active filter
Sort Sort by any column (asc/desc), supports size unit conversion
Show Index Mapping View field mappings and fetch sample data for a selected index
Delete an index Delete a single index (with confirmation)
Delete all indexes by filter Bulk delete all currently filtered indexes (with confirmation)

Testing

vendor/bin/simple-phpunit

Unit tests cover:

  • ListSorter — byte conversion, index sorting by various columns
  • FilterByNameOfIndexes — pattern matching filter
  • FilterNotEmptyIndexes — empty index filter

Integration tests require a running Symfony kernel with Elasticsearch connection.

License

MIT