[FEATURE] How to use indices()->putTemplate parameter
Hi there,
I am trying to create an Index Template via the SDK. As I can't find any documentation about, how do I use the method - the main question is: How must the parameter array be structured? Using the structure as of https://opensearch.org/docs/latest/im-plugin/index-templates/
as "body", i am getting always the error "No alive nodes found in your cluster". While creating an Index works.
A little documentation about would be very nice. And i hope somebody maybe has an example how to structure. This is my current structure (properties are added dynamically):
$indexTemplate = [ 'name' => 'Index Template', 'body' => [ 'index_patterns' => [ 'entity-v1-*' ], 'template' => [ 'settings' => [ 'number_of_shards' => $openSearchConfig['number_of_shards'], 'number_of_replicas' => $openSearchConfig['number_of_replicas'] ], 'mappings' => [ 'properties' => [] ] ], 'priority' => 200, 'version' => 1, '_meta' => [ 'description' => 'My Fancy Template.' ] ] ];
I also tried some ways I found for ElasticSearch - without any success. Would be great to get some unterstandings :) Thanks in advance!
Solved with that structure
[ 'name' => 'foobar', 'body' => [ "index_patterns" => [ "logs-2020-01-*" ], "template" => [ "aliases" => [ "my_logs" => [ ] ], "settings" => [ "number_of_shards" => 2, "number_of_replicas" => 0 ], "mappings" => [ "properties" => [ "timestamp" => [ "type" => "date", "format" => "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" ], "value" => [ "type" => "double" ] ] ] ] ] ]
We started adding guides and samples to various clients. @DIU-marc want to help? You could write a guide and a working sample for index templates. Something similar to https://github.com/opensearch-project/opensearch-py/blob/main/guides/index_template.md?
Hi @dblock Thanks for your reply. Sure, would be glad to do that.
Hello @DIU-marc,
I hope you're doing well. Whenever you find a moment, would you mind considering contributing by adding a guide?
Thank you!