pimcore / generic-data-index-bundle

Other
6 stars 4 forks source link

Indexing Data without the Index being created causes wrong index creation #202

Closed dpfaffenbauer closed 3 months ago

dpfaffenbauer commented 3 months ago

Weird title I know :D, but I found a issue with this bundle. It happens when you do the following:

  1. Delete all Indices from OpenSearch
  2. Save a Asset
  3. Run the messenger consumer pimcore_generic_data_index_sync
  4. Check the indices

You now see that there is a index called pimcore_asset whereas this should be an alias, index should be pimcore_asset-odd:

[opensearch@295bfea50da0 ~]$ curl localhost:9200/_cat/indices
green  open .plugins-ml-config        V_zqwSpmTdm_8RSPKRQVaQ 1 0 1 0  3.9kb  3.9kb
green  open .opensearch-observability Gfz56DguSJaboS7WcHinOA 1 0 0 0   208b   208b
yellow open pimcore_asset             wg9z8shCTkaDtPI-1U_1Cg 1 1 1 0 13.9kb 13.9kb

[opensearch@295bfea50da0 ~]$ curl localhost:9200/_cat/aliases
# No Result here

If I delete the indices again and run the rebuild index command, it works like it should:

[opensearch@295bfea50da0 ~]$ curl localhost:9200/_cat/indices
green open pimcore_asset-odd                        AqOxx3XjTPG0iwyPCA4zMw 1 0 0 0 208b 208b
[opensearch@295bfea50da0 ~]$ curl localhost:9200/_cat/aliases
pimcore_asset                        pimcore_asset-odd                        - - - -
pimcore_element-search               pimcore_asset-odd                        - - - -
markus-moser commented 3 months ago

Yes, that's the same which I tried to explain here:

https://github.com/pimcore/generic-data-index-bundle/issues/165#issuecomment-2244781785

dpfaffenbauer commented 3 months ago

ah gotcha, I somehow missed your response on that...

dpfaffenbauer commented 3 months ago

But: The Indexer should check if the index exists and create it if not

markus-moser commented 3 months ago

Not that easy to achieve - we would need one additional request for each indexing request which could be quite a bit of overhead. Still not have the best idea how to solve this. If you have a good idea please let me know...

dpfaffenbauer commented 3 months ago

yes, good point as well. Then lets add a doc about it: https://github.com/pimcore/generic-data-index-bundle/pull/203

This is quite important ;)