Calling Developers!
We are reenergizing our code contribution process! Learn More

Spryker: How to implement ES index recreation by switching the index on fly?

Options
PatrikTorn
PatrikTorn Software Developer Unconfirmed Posts: 1 🧑🏻‍🚀 - Cadet
edited February 26 in Spryker Development

We want to update ElasticSearch synonyms in “page” index. With current implementation, we first delete the index and then run ES reindex. This causes ~2h gap that all products aren’t visible.

$PHP_BIN vendor/bin/console elasticsearch:index:delete
$PHP_BIN vendor/bin/console search:setup:sources
$PHP_BIN vendor/bin/console publish:trigger-events

Does someone have any hints how to implement ES index recreation by switching the index on fly? Thanks!

Answers

  • Oleksandr Peresypkin
    Oleksandr Peresypkin Lead Demo Engineering Sprykee Posts: 22 🧑🏻‍🚀 - Cadet
    edited February 19
    Options

    You could try closing the needed indexes, updating the settings with the synonyms and opening the indexes again. In this case, you don't need to recreate them.

    Example to perform it on the fly:

    $this->elasticaClient->request(
        $indexName . '/_close',
        Request::POST,
    );
    
    // Read the page.json settings file into $settings and add the structure:
    
    $settings['analysis']['filter']['b2b_mp_synonyms']['synonyms'][] = "bench => chair";
    
    $this->elasticaClient->request(
        $indexName . '/_settings',
        Request::PUT,
        $settings,
    );
    
    $this->elasticaClient->request(
        $indexName . '/_open',
        Request::POST,
    );
    

    Caveat:

    The closed indexes can't be accessed before they are opened again.

  • profuel
    profuel SSA Sprykee Posts: 37 ✨ - Novice
    Options

    If your Spryker Project is working in our PaaS, and you're willing to do some additional work, I recommend you, @PatrikTorn, to look at this solution: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/custom-packages.html

    Here you will find complete solution with necessary automation supported by Lambda function.

  • mikko.ropanen
    mikko.ropanen Spryker Solution Partner Posts: 9 🧑🏻‍🚀 - Cadet
    Options

    How would you get started with this solution in practice? I think most people don't have the IAM permissions to create packages or Lambdas in the Spryker cloud.

  • profuel
    profuel SSA Sprykee Posts: 37 ✨ - Novice
    Options

    That's correct, to make this happen please create a support ticket explaining what you need, and attach the documentation and/or extracts from it.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,005 ⚖️ - Guardians (admin)
    Options

    btw, I just discovered that this topic is in the wrong subcategory - I will move it to the Spryker development questions :)

    All the best,

    Florian