弹性搜索索引模板 [英] Elasticsearch-groovy index template
问题描述
编辑:@Val感谢您的回复,但如果我使用来源
字段如下:
def templateR = client.admin.indices .putTemplate {
nametemplate_name
source {
templatetemplate_ *
}
} .actionGet()
...这导致编译器错误: MissingMethodException没有方法的签名:... source() code>。以下代码:
def templateR = client.admin.indices.putTemplate {
namelemato_template
模板lemato_ *
设置{
number_of_shards = 1
}
} .actionGet()
给我编译器错误没有这样的属性:number_of_shards
。我不知道我是否使用封闭委员会a>正确。是否像 .asMap()
缺少?
elasticsearch-groovy绝对支持创建/删除索引模板。 来源
关闭可能包含您可以为索引模板。这样的事情应该有效。
PutIndexTemplateResponse response = client.admin.indices.putTemplate {
namemy_template
source {
templateindex_ *
settings {
index {
number_of_shards = 5
number_of_replicas = 1
}
}
mappings {
//你的映射定义
}
aliases {
//你的别名
}
}
} .actionGet()
Is there any way to define an index template with the API of elasticsearch-groovy or elasticsearch-java? I want to apply "settings" (custom analyzers) and "mappings" (apply analyzer on fields) on it. The documentation only refers to index templatex but does not show a vaild example, how to apply them in a groovy closure. The example shown in the docs, adds the "settings" in the data (source) field.
edit: @Val Thank you for your reply, but if I use the source
field as follows:
def templateR = client.admin.indices.putTemplate {
name "template_name"
source {
template "template_*"
}
}.actionGet()
... this results in a compiler-error: MissingMethodException No signature of method: ...source()
. The following code:
def templateR = client.admin.indices.putTemplate {
name "lemato_template"
template "lemato_*"
settings {
number_of_shards= 1
}
}.actionGet()
gives me the compiler error No such property: number_of_shards
. I'm not sure if I use the closure delegation correctly. Is something like .asMap()
missing?
elasticsearch-groovy definitely provides support for creating/deleting index templates. The source
closure may contain anything you can define for index templates. Something like this should work.
PutIndexTemplateResponse response = client.admin.indices.putTemplate {
name "my_template"
source {
template "index_*"
settings {
index {
number_of_shards = 5
number_of_replicas = 1
}
}
mappings {
// your mapping definitions
}
aliases {
// your aliases
}
}
}.actionGet()
这篇关于弹性搜索索引模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!