-
Notifications
You must be signed in to change notification settings - Fork 41
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] dynamic index_class_mapping ? #173
Comments
hello So I managed to handle this with a custom In my case, all I had to do was overwriting then, when consuming the service, instead of doing $index = $this->esClient->getIndex($indexName);
$query = .... ;
$response = $index->search($query, ['limit' => 30], Request::GET); did $index = $this->esClient->getIndex($indexName);
$query = .... ;
$search = $index->createSearch($query, ['limit' => 30], $myCustomResultBuilder);
$response = $search->search('', null, Request::GET); yet.... I find this really over-complicated, just to inject a custom class mapping at runtime
If PRs are accepted for either option, let me know... |
Hello, thanks for this detailed report! This library does not support wildcard for class to index mapping as you found out.
You should be able to do the second one. Line 34 in 2a97fc8
So you can just inject your custom one when creating the Client, which depending on your framework / context may differ. |
thanks for getting back at me.... yet... this does not seem very efficient so wondered if I submit a PR to enable:
it would have a chance to be merged... |
We tend to avoid adding options and features to keep the library easy to maintain 😬 - so my first answer would be to not accept such PR. BUT there is room for improvement, we could do like we did for the mapping provider. We added a MappingProviderInterface allowing users to bring their own mapping the way the want (Yaml, Php, Json... whatever). We could add a IndexNameMapperInterface, and make it easier / clearer how to switch from one to another. WDYT? Cheers. |
I can do that.... |
hello,
so I need to build a lot of indexes...
the naming of these indexes is dynamic, but I do use a predefined prefix
av_%%indexname%%
all the indexes do use the same mapping and map to the same class
as the naming is dynamic, I can not list all of them in the configuration...
at runtime, the request tells me on which index I should use.
requests work fine...
BUT when building the resultSet at the end of
\Elastica\Search::search
, using the injectedBuilderInterface
the request fails because the class mapping is unknownso before looking into injecting a custom
BuilderInterface
, I was wondering if there were ways to either use wildcards for the mapping or inject a mapping at runtime ?thanks a lot
Dmitri
The text was updated successfully, but these errors were encountered: