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
Index templates support #1343
Index templates support #1343
Conversation
@torinaki Are you still working on this? |
@XWB yes. I will try to actualize this next week. Anyway, it is already working code because we are already using this implementation on production and it is integrated into our deployment pipeline. |
@XWB I've updated brach with a fresh master. Will continue work ASAP |
👍 |
@torinaki any progress? Currently this bundle is kind of unusable with Elastic 6.x, with 10 indexes that need 15 exactly same analyzers/filters the config looks like programmer's worst nightmare. Because of that together with the lack of multiindex services I will have to revert back to 5.x. |
@Destroy666x You can reuse blocks and merge with yaml if that helps. |
@nicholasruunu the solution is also a bit clunky, but better than the previous mess, I guess. However, it doesn't seem to work inside Symfony's .yml.
Symfony complains that no configuration for |
@Destroy666x I think you misunderstand how it works, the only thing you add is the Then you can paste with |
Ah yes, then that's even more clunky. But it'll work as temporary solution before this gets implemented. Thanks for help! |
@Destroy666x np If you want to do it in a more template-like way, I believe you could use x-vars:
or
|
@Destroy666x we already using this code on production but in the scope of our own fork with a little bit outdated version of this bundle. I will do last push make it work for the latest version. |
I did some refactoring of initial implementation to make code less coupled and BC safe. Now I'm working on tests and bug fixes |
c8ce323
to
7706aa3
Compare
16ffdc6
to
5d25175
Compare
@XWB I have squashed commits |
@XWB can you please take a look at this PR? |
� Conflicts: � tests/Unit/DependencyInjection/ConfigurationTest.php � tests/Unit/Elastica/ClientTest.php
5d25175
to
9cfd0f1
Compare
@XWB I've adjusted code according to comments. Also, added one documentation page about index templates. |
Thanks for the hard work @torinaki :) |
@XWB thanks you for your time and patience 😃 |
Hi @dbalabka, Sorry to unearth the subject but I tried your feature, it's working fine until a new object is insert/updated in one of the index. Then it automatically reset the replicas to 1 whereas my parameter is set to 0. Any idea what could be wrong on my side ? Thanks in advance for any help, |
@pesseyjulien so if initially your setting value is 0 then it should not be a bug the implementation. Try to take a look into follow discussion on Elastic forum: https://discuss.elastic.co/t/change-number-of-replicas-to-0-on-existing-indices/141622 There might be a relationship with new setting auto_expand_replicas |
Nop, modifying the settings works but then if I save an object in ES, it reverts to replica : 1 I don't understand why.. My templates :
With :
What I do : Reset templates
Result :
Save an object in the index -> revert back to
|
@pesseyjulien please validate that template settings are created correctly using GET API https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-template.html |
Looks like it
Maybe the index pattern is wrong ? Thanks, |
@pesseyjulien so it seems that the template has been created correctly: {
//...
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "0"
}
},
//...
} So, the code works correctly. It might be related to your Elastica settings. I suspect that I suggest addressing your question to https://discuss.elastic.co community. |
Turns out it was a limitation of Bonsai (my ES provider).. Thanks a lot for the help anyway, |
@pesseyjulien curious how it is possible to set such limits and what is the reason? |
Well this is their answer :
I only use it for my test environnement but they have a shard limit, this is why I wanted no replication but they increased my limit in response, so it's ok for now. |
Original PR #917
Scope
This PR implements Elastica Index Templates functionality via bundle configuration. Index Templates widely is used to create historically indexes:
YAML configuration files:
To apply templates changes we have created new command
fos:elastica:reset-templates
with options:--index
- index template to reset. If no index template name specified than all templates will be reset--force-delete
- will delete all indexes that matches index templates patterns. Aware that pattern may match various indexes.You must run the following command to sync templates configuration on ES server with YAML configurations:
You can build-in this command into the deployment process to automate template configuration sync.
Future scope
There should be a possibility to create historical indexes with the possibility to generate index name on the fly based on some strategy (typically using current date)
Example
In the following example, we have an index with name
user_searches_history_YYYYMM
and index templateuser_searches_history_template
.Index
user_searches_history_YYYYMM
contains placeholder -YYYYMM
which will be replaced with current year and month.We do not need to set an index mapping explicitly. Instead, each added document might create a new index (if it not exists) with populated mapping from
user_searches_history_template
index template configuration, because of patternuser_searches_history_*
will match any ofuser_searches_history_YYYYMM
indexes.TODO