ES操作文档记录

阅读 77

2022-07-12

ES的Restful API

参考文档: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rest-apis.html

ES的Mapping定义

参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.17/mapping.html

ES的search接口

参考文档:
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-your-data.html
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-filter-context.html

ES创建index模板

  • PUT _index_template/templateId
{
"index_patterns": [
"haihui_items_index*"
],
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "haihui_items_index_policy"
},
"number_of_shards": "3",
"number_of_replicas": "2"
}
},
"mappings": {
"_routing": {
"required": false
},
"numeric_detection": false,
"dynamic_date_formats": [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
],
"_source": {
"excludes": [ ],
"includes": [ ],
"enabled": true
},
"dynamic": true,
"dynamic_templates": [ ],
"date_detection": true,
"properties": {
"score": {
"type": "double"
},
"item_id": {
"type": "keyword"
}
}
}
},
"composed_of": [ ],
"priority": 100,
"version": 1,
"_meta": {
"description": "haihui items index template by x-pack",
"managed": true
},
"data_stream": {
"hidden": false
}
}

创建管理的index的lifetime

  • PUT _ilm/policy/my_policy
{
"policy": {
"_meta": {
"description": "used for nginx log",
"project": {
"name": "myProject",
"department": "myDepartment"
}
},
"phases": {
"warm": {
"min_age": "10d",
"actions": {
"forcemerge": {
"max_num_segments": 1
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {}
}
}
}
}
}

ES定义index

  • PUT /myIndex
{
"index_templates" : [
{
"name" : "haihui_items_index_template",
"index_template" : {
"index_patterns" : [
"haihui_items_index*"
],
"template" : {
"settings" : {
"index" : {
"lifecycle" : {
"name" : "haihui_items_index_policy"
},
"number_of_shards" : "3",
"number_of_replicas" : "2"
}
},
"mappings" : {
"_routing" : {
"required" : false
},
"numeric_detection" : false,
"dynamic_date_formats" : [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
],
"_source" : {
"excludes" : [ ],
"includes" : [ ],
"enabled" : true
},
"dynamic" : true,
"dynamic_templates" : [ ],
"date_detection" : true,
"properties" : {
"score" : {
"type" : "double"
},
"item_id" : {
"type" : "keyword"
}
}
}
},
"composed_of" : [ ],
"priority" : 100,
"version" : 1,
"_meta" : {
"description" : "haihui items index template by x-pack",
"managed" : true
},
"data_stream" : {
"hidden" : false
}
}
}
]
}


精彩评论(0)

0 0 举报