当前位置: 首页 > news >正文

Elasticsearch 认证模拟题 - 1

1、题目

定义一个数据流,满足 data-stream_*_*,数据首先分布在 data_hot,5分钟后移动到 data_warm,3分钟后到 data_cold,再过 8 分钟删除。

1.1 考点
  1. 生命周期
  2. 索引模板
  3. 数据流
1.2 答案
# 修改生命周期策略修改时间
PUT /_cluster/settings
{"persistent": {"indices.lifecycle.poll_interval": "1m"},"transient": {"indices.lifecycle.poll_interval": "1m"}
}# 创建策略
PUT _ilm/policy/policy_8m
{"policy": {"phases": {"hot": {"min_age": "0ms","actions": {}}, "warm": {"min_age": "1m","actions": {}},"delete": {"min_age": "2m","actions": {"delete": {}}}}}
}# 创建模板
PUT _index_template/policy_8m_template
{"index_patterns": ["data-stream_*_*"],"template": {"settings": {"number_of_shards": 3,"index.lifecycle.name": "policy_8m"}},"data_stream": { },"priority": 500
}# 创建一个数据流
PUT _data_stream/data-stream_05_27# 向数据流写入数据
PUT data-stream_05_27/_bulk
{ "create":{ } }
{ "@timestamp": "2099-05-06T16:21:15.000Z", "message": "192.0.2.42 - - [06/May/2099:16:21:15 +0000] \"GET /images/bg.jpg HTTP/1.0\" 200 24736" }
{ "create":{ } }
{ "@timestamp": "2099-05-06T16:25:42.000Z", "message": "192.0.2.255 - - [06/May/2099:16:25:42 +0000] \"GET /favicon.ico HTTP/1.0\" 200 3638" }

注: 数据流至少对应一个隐藏索引

2、题目

有一个索引 task2,存在 field2 字段,用 match 匹配 the 能查到很多数据,现要求对 task2 索引进行重建,达到使用 match 匹配 the 不能查询到数据的目的。

# 创建符合条件的 task2 索引,设置 field2 字段,并写入数据,简单查询
PUT task2
{"mappings": {"properties": {"field2":{"type": "text"}}}
}POST task2/_bulk
{"index": {}}
{"field2":"the school"}
{"index": {}}
{"field2":"the apple"}
{"index": {}}
{"field2":"the world"}GET task2/_search
{"query": {"match": {"field2": "the"}}
}

在这里插入图片描述

2.1 考点
  1. match匹配查询
  2. 分词器的使用
    • 2.1 Character filters: 字符过滤器
    • 2.2 Tokenizer: 分词器
    • 2.3 Token filter: 词过滤器
  3. 索引重建
3.2 答案
# 定义索引 task3,自定义分词器 my_custom_analyzer,
PUT task3
{"settings": {"analysis": {"analyzer": {"my_custom_analyzer": { "char_filter": [ ],"tokenizer": "standard","filter": ["lowercase","english_stop"]}},"char_filter": {"emoticons": { "type": "mapping","mappings": ["the => "]}},"filter": {"english_stop": { "type": "stop","stopwords": [ "the" ]}}}},"mappings": {"properties": {"field2": {"type": "text","analyzer": "my_custom_analyzer"}}}
}# 重建索引 task2 的数据 到 task3
POST _reindex
{"source": {"index": "task2"},"dest": {"index": "task3"}
}# 查询
GET task3/_search
GET task3/_search
{"query": {"match": {"field2": "the"}}
}

在这里插入图片描述

相关文章:

  • 钉钉企业内部H5微应用或小程序之钉消息推送
  • 赛事|基于SprinBoot+vue的CSGO赛事管理系统(源码+数据库+文档)
  • Python库之Scrapy的高级用法深度解析
  • MySQL 状态【中文对照表】
  • Java应用中文件上传安全性分析与安全实践
  • ModuleNotFoundError: No module named ‘import_export‘
  • 《TCP/IP网络编程》(第十二章)I/O复用(1)
  • 嵌入式学习记录5.18(多点通信)
  • Node.js和npm常用命令
  • element-ui组件table去除下方滚动条,实现鼠标左右拖拽移动表格
  • 四、通信和网络安全—局域网|广域网|远程连接和攻击技术(CISSP)
  • 让大模型更聪明——复杂而艰巨的任务
  • C++类与对象的特性
  • 【算法刷题day60】Leetcode:84. 柱状图中最大的矩形
  • 大规模语言模型的书籍分享
  • 345-反转字符串中的元音字母
  • ECMAScript 6 学习之路 ( 四 ) String 字符串扩展
  • js正则,这点儿就够用了
  • JS专题之继承
  • ng6--错误信息小结(持续更新)
  • php的插入排序,通过双层for循环
  • PHP那些事儿
  • Promise面试题,控制异步流程
  • 搞机器学习要哪些技能
  • 树莓派 - 使用须知
  • 想写好前端,先练好内功
  • 译自由幺半群
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • ​你们这样子,耽误我的工作进度怎么办?
  • !!【OpenCV学习】计算两幅图像的重叠区域
  • # SpringBoot 如何让指定的Bean先加载
  • #ifdef 的技巧用法
  • #设计模式#4.6 Flyweight(享元) 对象结构型模式
  • #数学建模# 线性规划问题的Matlab求解
  • (2024最新)CentOS 7上在线安装MySQL 5.7|喂饭级教程
  • (30)数组元素和与数字和的绝对差
  • (void) (_x == _y)的作用
  • (附源码)springboot建达集团公司平台 毕业设计 141538
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (三) diretfbrc详解
  • (四)js前端开发中设计模式之工厂方法模式
  • (完整代码)R语言中利用SVM-RFE机器学习算法筛选关键因子
  • (一)Thymeleaf用法——Thymeleaf简介
  • (转)IIS6 ASP 0251超过响应缓冲区限制错误的解决方法
  • (转载)hibernate缓存
  • ******之网络***——物理***
  • .NET Micro Framework初体验(二)
  • .net/c# memcached 获取所有缓存键(keys)
  • .net6 webapi log4net完整配置使用流程
  • .Net接口调试与案例
  • .NET上SQLite的连接
  • .net下简单快捷的数值高低位切换
  • /bin、/sbin、/usr/bin、/usr/sbin
  • /bin/bash^M: bad interpreter: No such file ordirectory
  • /usr/bin/perl:bad interpreter:No such file or directory 的解决办法