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

[FEATURE] How to use indices()->putTemplate parameter #176

Open
DIU-marc opened this issue Mar 2, 2024 · 4 comments
Open

[FEATURE] How to use indices()->putTemplate parameter #176

DIU-marc opened this issue Mar 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@DIU-marc
Copy link

DIU-marc commented Mar 2, 2024

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!

@DIU-marc DIU-marc added enhancement New feature or request untriaged labels Mar 2, 2024
@DIU-marc
Copy link
Author

DIU-marc commented Mar 2, 2024

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" ] ] ] ] ] ]

@dblock
Copy link
Member

dblock commented Mar 4, 2024

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?

@DIU-marc
Copy link
Author

DIU-marc commented Mar 7, 2024

Hi @dblock
Thanks for your reply. Sure, would be glad to do that.

@dblock dblock removed the untriaged label Mar 28, 2024
@saimedhi
Copy link
Collaborator

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!

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

No branches or pull requests

3 participants