Skip to content

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

Open
@macghriogair

Description

@macghriogair

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

  • Bundle Versions: 6.7.2 and 7.x
  • Elasticsearch Version: 6.7 and 7.6
  • PHP Version 7.4

Expected behaviour:

  • --index option should be either required OR commands should be executed on all indices (where possible)

Actual behaviour:

  • an unpredictable index is used when commands are executed without --index

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

  • ongr:es:cache:clear
  • ongr:es:index:create
  • ongr:es:index:drop
  • ongr:es:index:export
  • ongr:es:index:import

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions