[英]Elasticsearch Single analyzer across multiple index
I have time-based indices我有基于时间的索引
students-2018学生-2018
students-2019学生-2019
students-2020学生-2020
I have defined 1 analyzer with synonyms, I want to reuse the same analyzer across multiple indexes, how do I achieve that?我已经定义了 1 个具有同义词的分析器,我想在多个索引中重用同一个分析器,我该如何实现?
You can define an index template and then create your custom analyzer with that template which includes all your student
indices.您可以定义一个索引模板,然后使用包含所有
student
索引的该模板创建您的自定义分析器。
You can add your index-pattern in below index template call as mention in the official doc .您可以在下面的索引模板调用中添加您的索引模式,如官方文档中所述。
Sample index template def样本索引模板定义
{
"index_patterns": ["student-*"],
"settings": {
"analysis": {
"analyzer": {
"my_custom_analyzer": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [
"html_strip"
],
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
}
}
Now all your student indices like students-2018
, students-2019
will have this my_custom_analyzer
which is defined in the index template.现在,您的所有学生索引(例如
students-2018
、 students-2019
)都将具有在索引模板中定义的my_custom_analyzer
。
Create a student index without any setting and analyzer like无需任何设置和分析器即可创建学生索引
http://{{you-es-hostname}}/student-2018
And then check its setting using GET http://{{you-es-hostname}}/student-2018
, which would give below output and includes the analyzer created in the index template.然后使用
GET http://{{you-es-hostname}}/student-2018
检查其设置,这将给出 output 并包括在索引模板中创建的分析器。
{
"student-2018": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "student-2018",
"creation_date": "1588653678067",
"analysis": {
"analyzer": {
"my_custom_analyzer": {
"filter": [
"lowercase",
"asciifolding"
],
"char_filter": [
"html_strip"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"uuid": "kjGEgKCOSJeIlrASP-RaMQ",
"version": {
"created": "7040299"
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.