-
Notifications
You must be signed in to change notification settings - Fork 30
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
Added a custom repository method for indexation with "meilisearch:import" command #345
base: main
Are you sure you want to change the base?
Added a custom repository method for indexation with "meilisearch:import" command #345
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #345 +/- ##
============================================
+ Coverage 87.75% 88.17% +0.41%
Complexity 1 1
============================================
Files 20 21 +1
Lines 874 905 +31
============================================
+ Hits 767 798 +31
Misses 107 107 ☔ View full report in Codecov by Sentry. |
Thanks,but I'm not sure it's worth it to introduce this option that we'll need to deprecate it, because the goal is to allow supporting indexing from more than orm source, which will open better extensibility. |
@norkunas what about an interface like If you think this would be ok for you, I'll be glad to update this PR. |
Basically it's the same as data provider. |
@norkunas I named it "DataProvider" and it handles batches as you recommended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I've started to make something similar to this, I saw that current SearchService depends on the orm.. I think it's a subject for a deprecation and introduction for a new interface without dependency on it.
Also one of my goals was to introduce Importer service or something similarly named, which would be injected to import command, and we'd have possibility to import manually outside of cli
*/ | ||
private function getEntities($prefixedIndexName, $entityClassName, $batchSize, $page): array | ||
{ | ||
$dataProvider = $this->searchService->getDataProvider($this->getIndexNameWithoutPrefix($prefixedIndexName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use ServiceLocator from Symfony instead of coupling this to the SearchService..
->scalarNode('data_provider') | ||
->info('Method of the entity repository called when the meilisearch:import command is invoked.') | ||
->defaultNull() | ||
->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should introduce something like:
persistence:
driver: orm # later odm, custom (default to orm, to not introduce BC break immediately)
data_provider: null # if set, use it, otherwise register the default orm provider and add it to service locator
* | ||
* @return array | ||
*/ | ||
public function getAll(int $limit = 100, int $offset = 0): array; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function getAll(int $limit = 100, int $offset = 0): array; | |
public function provide(int $limit = 100, int $offset = 0): array; |
maybe ? :)
|
||
namespace Meilisearch\Bundle\DataProvider; | ||
|
||
interface DataProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface DataProvider | |
/** | |
* @template T of object | |
*/ | |
interface DataProvider |
* @param int $limit | ||
* @param int $offset | ||
* | ||
* @return array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return array | |
* @return array<T> |
public function setEntityClassName(string $entityClassName): void | ||
{ | ||
$this->entityClassName = $entityClassName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why making this stateful? I'd register this provider as a separate service for each index and pass the class name via constructor
sorry, I'm on a paternal leave, and rushed to reply, instead I wanted to say that the best fit would be |
Pull Request
Related issue
Fixes #344
What does this PR do?
repository_method
in the indicesmeilisearch:import
is invoked, this method is used instead of "findBy"PR checklist
Please check if your PR fulfills the following requirements:
I will be happy to hear any feedback and make changes to this PR if needed.