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

The indexer does not use the IndexNameMapper #168

Open
Nek- opened this issue May 26, 2023 · 3 comments
Open

The indexer does not use the IndexNameMapper #168

Nek- opened this issue May 26, 2023 · 3 comments

Comments

@Nek-
Copy link
Contributor

Nek- commented May 26, 2023

Because the IndexNameMapper does not use the indexNameMapper, the prefix is never added to the index name. However, the IndexBuilder is using it and works with the prefix! It's highly disturbing.

$document->setIndex($index instanceof Index ? $index->getName() : $index);

@lyrixx
Copy link
Member

lyrixx commented May 30, 2023

Thanks for the report. Do you want to give it a try?

@BorbagUskada
Copy link

BorbagUskada commented Jun 16, 2023

What is your goto ? Using the indexNameMapper everywhere ?

Along with the issue reported by @Nek- , one consequence is that I see no way as for now to retrieve dynamically Index instance solely from a class, but maybe I am missing something.

The IndexNameMapper contains several methods to return a prefixed index name based on a class, but no way to retrieve non-prefixed index name. And since the getIndex(string $name) method of Client automatically prefix the given name, there's no way but to get double-prefixed index name, which means the getIndex has to be called with a non-dynamic non-prefixed index name (not crystal clear but I guess you get it).

I could take a look at it but I'd like to know the exact scope of it, since this seems to be a BC break.

@damienalexandre
Copy link
Member

You are supposed to call Client->getIndex() to get a Index.

public function getIndex(string $name): \Elastica\Index

That means you should now the that Class FOO belong to index "yop".

If your application does not have this information, you could expose the config elsewhere:

elastically_index_class_mapping:
hop: JoliCode\Elastically\Tests\Messenger\TestDTO

Or maybe we should add a helper in the Client, like "getIndexFromObject"? Would that help?

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

No branches or pull requests

4 participants