从jsl生成elasticsearch模板
jsl-elasticsearch的Python项目详细描述
jsl_elasticsearch从jsl定义生成elasticsearch映射。
它需要python 3.4或更高版本(主要用于functools.singledispatch)。
它特别针对使用elasticsearch作为 使用 jslpython库。
主要的api是jsl_elasticsearch.render_es_template:
def render_es_template(document, title, role, doc_type="content"): """Render an ElasticSearch time series template for given JSL document Template name is generated from the given *title* and *role* Document variables are resolved using the given *role* *doc_type* specifies the ElasticSearch mapping name (default: "content") """
kibana需要的@timestamp字段将自动添加,并且 默认情况下,字符串字段标记为not_analyzed(因此elasticsearch 将它们视为不透明的标记,而不是将其视为 分析以进行全文搜索)
当前支持以下JSL字段类型:
- jsl.StringField
- jsl.NumberField
- jsl.IntField
- jsl.ArrayField
- jsl.DictField
- jsl.DocumentField
另外还定义了一个字段类型:
- jsl_elasticsearch.TextField
默认情况下,字符串字段标记为不透明标记,TextField 是一个新的StringField子类,它为全文搜索标记字段 在ElasticSearch映射中,但在其他方面的处理方式与 StringField由jsl编写。