In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use dynamic_templates in Elasticsearch". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use dynamic_templates in Elasticsearch".
I.
With dynamic_templates, you can fully control the mapping of new fields, and you can apply a completely different mapping by field name or data type.
Each template has a name to describe the purpose of the template, a mapping field to guide how the mapping is used, and at least one parameter match to define which field the template uses. Templates are detected sequentially, and the first matching template is enabled. Usually put the specific template in the first place, otherwise the universal template will match, resulting in the specific can not be matched.
Note: the following are all operated on sense
Example: we create separately for / my_index/my_type
Es: if the field name ends with _ es and is of type string, you need to use a spanish word splitter
Enn: for other fields and of type string, you need to use the english word splitter
DELETE / my_indexPUT / my_index {"mappings": {"my_type": {"dynamic_templates": [{"es": {= > template name, feel free Generally, there should be semantic "match": "* _ es", = > matching field name "match_mapping_type": "string" = > matching field type "mapping": {= > when the match is reached. The specific settings for this field are "type": "string", "anaylzer": "spanish"} {"en": {= > template name Optional, generally have the semantic "match": "*", = > match the field name (any The general order is after) "match_mapping_type": "string" = > match field type "mapping": {= > after matching Specific settings for this field "type": "string", "anaylzer": "english"} POST / my_index/my_type {"str_es": "xxx" = > match es (field names match Type matching) "long_es": 123, = > does not match es (field names match, but types do not match) "date_es": "2015-01-01", = > does not match es (field names match, but types do not match) "long_en": 123, = > does not match en (field names match But the type does not match) "str_en": "xxx", = > match en (field names match, but type mismatch) "date_en": "2015-01-01" = > does not match en (field names match, but type mismatch)} / / mapping is as follows It is the result GET / my_index/my_type {"my_index": {"mappings": {"my_type": {"dynamic_templates": [{"es": {"mapping": {"analyzer": "spanish" "type": "string"}, "match": "* _ es", "match_mapping_type": "string"}} {"en": {"mapping": {"analyzer": "english", "type": "string"}, "match": "*" "match_mapping_type": "string"}], "properties": {"date_en": {"type": "date", "format": "dateOptionalTime"} "date_es": {"type": "date", "format": "dateOptionalTime"}, "long_en": {"type": "long"} "long_es": {"type": "long"}, "str_en": {"type": "string", "analyzer": "english"} "str_es": {"type": "string", "analyzer": "spanish"}, "str_es2": {"type": "string" "analyzer": "english"}} II. Default mapping _ default_ usually all types in an index have shared fields and settings It is more convenient to specify with the _ default_ mapping, rather than repeating the operation to create a type one at a time. Default_ mapping new types of templates, unless in their own type of clear coverage thank you for reading, the above is "how to use Elasticsearch dynamic_templates" of the content, after the study of this article, I believe you have a deeper understanding of how to use Elasticsearch dynamic_templates, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.