ES操作文档记录

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
        }
      }
    }
  ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疾风先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值