Index Templates API - Source


(Nicolas Huray) #1

Hi Shay,

Is there's a way with the Java client API to create a template and set the
source like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template").
.setSource(sourceTemplate)
.execute()
.actionGet();

where source is a json object like :

{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}

instead to set setting, mappings ... like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template")
.setTemplate("twitter*")
.addMapping("tweet", sourceMapping)
.setSettings(sourceSettings)
.execute()
.actionGet();

Thank you in advance for your response


(Shay Banon) #2

No, there isn't a way to do it, but we can support it if needed (thats what
the REST endpoint does).

On Thu, Apr 12, 2012 at 7:30 PM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Is there's a way with the Java client API to create a template and set the
source like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template").
.setSource(sourceTemplate)
.execute()
.actionGet();

where source is a json object like :

{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}

instead to set setting, mappings ... like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template")
.setTemplate("twitter*")
.addMapping("tweet", sourceMapping)
.setSettings(sourceSettings)
.execute()
.actionGet();

Thank you in advance for your response


(Nicolas Huray) #3

Hi Shay,

Thank you for your response. I think I'll submit you a pull request if I
had a little time for that.

Le vendredi 13 avril 2012 14:28:14 UTC+2, kimchy a écrit :

No, there isn't a way to do it, but we can support it if needed (thats
what the REST endpoint does).

On Thu, Apr 12, 2012 at 7:30 PM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Is there's a way with the Java client API to create a template and set
the source like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template").
.setSource(sourceTemplate)
.execute()
.actionGet();

where source is a json object like :

{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}

instead to set setting, mappings ... like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_template")
.setTemplate("twitter*")
.addMapping("tweet", sourceMapping)
.setSettings(sourceSettings)
.execute()
.actionGet();

Thank you in advance for your response


(Shay Banon) #4

Can you open an issue just in case? We basically need to move the parsing
logic from the rest put index template method into a "setSource" method on
the PutIndexTemplateRequest.

On Sat, Apr 14, 2012 at 1:47 AM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Thank you for your response. I think I'll submit you a pull request if I
had a little time for that.

Le vendredi 13 avril 2012 14:28:14 UTC+2, kimchy a écrit :

No, there isn't a way to do it, but we can support it if needed (thats
what the REST endpoint does).

On Thu, Apr 12, 2012 at 7:30 PM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Is there's a way with the Java client API to create a template and set
the source like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_**template").
.setSource(sourceTemplate)
.execute()
.actionGet();

where source is a json object like :

{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}

instead to set setting, mappings ... like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_*template")
.setTemplate("twitter
")
.addMapping("tweet", sourceMapping)
.setSettings(sourceSettings)
.execute()
.actionGet();

Thank you in advance for your response


(Nicolas Huray) #5

Hi Shay,

I've just submit you a pull request to fix this issue :

Regards,

Le samedi 14 avril 2012 19:19:22 UTC+2, kimchy a écrit :

Can you open an issue just in case? We basically need to move the parsing
logic from the rest put index template method into a "setSource" method on
the PutIndexTemplateRequest.

On Sat, Apr 14, 2012 at 1:47 AM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Thank you for your response. I think I'll submit you a pull request if I
had a little time for that.

Le vendredi 13 avril 2012 14:28:14 UTC+2, kimchy a écrit :

No, there isn't a way to do it, but we can support it if needed (thats
what the REST endpoint does).

On Thu, Apr 12, 2012 at 7:30 PM, Nicolas Huray nicolas.huray@gmail.comwrote:

Hi Shay,

Is there's a way with the Java client API to create a template and set
the source like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_**template").
.setSource(sourceTemplate)
.execute()
.actionGet();

where source is a json object like :

{
"template" : "te*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false }
}
}
}

instead to set setting, mappings ... like that :

PutIndexTemplateResponse response = client.admin().indices()
.preparePutTemplate("twitter_*template")
.setTemplate("twitter
")
.addMapping("tweet", sourceMapping)
.setSettings(sourceSettings)
.execute()
.actionGet();

Thank you in advance for your response


(thaidoan) #6

Hi Shay,

Was the issue fixed in the latest version (0.19.3), yet?

Regards, Thai


(system) #7