ongr-io / ElasticsearchBundle

Symfony bundle for Elasticsearch with steroids
MIT License
313 stars 189 forks source link

CLI command behaviour unpredictable when run without --index option and multiple indices #966

Open macghriogair opened 3 years ago

macghriogair commented 3 years ago

ONGR cli commands act on unpredictable indices when executed without --index option

Expected behaviour:

Actual behaviour:

Steps to reproduce:

Having mutliple indices + document classes:

config.yml


ongr_elasticsearch:
    # ...
    indexes:
            AppBundle\Search\Document\AcmeApple:
                alias: acme_apples
                hosts:
                    - '%elasticsearch.host%'
            AppBundle\Search\Document\AcmeBanana:
                alias: acme_banana
                hosts:
                    - '%elasticsearch.host%'
            AppBundle\Search\Document\AcmePotatoe:
                alias: acme_potatoe
                hosts:
                    - '%elasticsearch.host%'

Any of the following commands will be executed on just one index

Console output:


# Drop indices
www-data@41995e1973b5:/php$ bin/console ongr:es:index:drop -f

 The index `acme_banana` was successfully dropped.
# Create indices
www-data@41995e1973b5:/php$ bin/console ongr:es:index:create

 Created `acme_banana` index.

# Clear cache
www-data@41995e1973b5:/php$ bin/console ongr:es:cache:clear

 [OK] Elasticsearch `acme_banana` index cache has been cleared.

# Export
 www-data@41995e1973b5:/php$ bin/console ongr:es:index:export foo.json
# foo contains data of index `acme_banana`
# and so on...

Our workaround is a bash script to loop over all indices for tasks such as mapping updates/cache clear/reindex etc.