Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow programmatic (+ atomic) full reindex / import #345

Open
apfelbox opened this issue May 5, 2020 · 5 comments
Open

Comments

@apfelbox
Copy link

apfelbox commented May 5, 2020

  • Symfony version: 5.0+
  • Algolia Search Bundle version: any
  • Algolia Client Version: any
  • Language Version: any

Description

It would be really great if you could extract the logic in SearchImportCommand into a separate service, so that one can easily do an atomatic full reimport programmatically. Currently you have to manually build fake CLI arguments and call the command, which is quite awkward (or copy & paste the complete code, which is just as awkward).

Steps To Reproduce

n/a

@chloelbn
Copy link
Contributor

Hi @apfelbox, sorry but I'm not sure I fully understand your need. Would you mind providing example of what you're trying to achieve?

Thanks in advance

@apfelbox
Copy link
Author

apfelbox commented Sep 1, 2020

Yeah, sure

Often times, we have an internal importer that is importing data in an internal command. We disable automatice Doctrine-based indexing for the duration of the import (for performance reasons) and do a complete reimport afterwards.

It would be great if this complete reimport could be done with just an internal service.

@chloelbn
Copy link
Contributor

@apfelbox do you mean something like what was provided in this feature?

@apfelbox
Copy link
Author

Not really.

Right now, if I want to do a full reimport programmatically, so from my Symfony application, I have two options:

  1. call the SearchImportCommand::execute() directly – which is a heavy code smell
  2. call the console command like this: https://symfony.com/doc/current/console/command_in_controller.html – which is also a heavy code smell.

When all I want to do is

class MyClass
{
    public function __construct (private AlgoliaIndexer $indexer)
    {
    }

    public function doSth ()
    { 
        $this->indexer->reimportAtomic("my-index");
    }
}

All the functionality for doing a reimport is encapsulated in the console command right now, while it should be encapsulated in an internal service (class) that is then called from the console command.
And that internal service class is also callable from my internal code.

@chloelbn
Copy link
Contributor

Okay! I misread your need and got confused. I see what you mean, what's happening in the -Command class could indeed be extracted in an external service. Would you feel up to submitting a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants