09.需要加强练习

2024-08-31 15:48
文章标签 需要 练习 加强 09

本文主要是介绍09.需要加强练习,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

    • 1. 集群配置
    • 2. security一个单节点的集群
    • 3. 使用api来创建role,user,并使用kibana登录测试
    • 4. script的使用题型
    • 5. search template 使用方式
    • 6. pipeline使用
    • 7. index filter的使用场景
    • 8. search中的几个组合查询,附加alias
    • 9. cross_cluster search
    • 10. snapshot restore
    • 11. dynaic_maping and template
    • 12. join mapping

1. 集群配置

  1. 有三个节点,node1是专用的master
  2. node2,node3是data+ingest节点
  3. ip node1 192.168.1.123, 192.168.1.124,192.168.1.125

2. security一个单节点的集群

对单节点进行security操作,elastic的初始化密码为elastic-password
其余账户的也是如此
和下面的创建用户可以同时使用

3. 使用api来创建role,user,并使用kibana登录测试

创建一个role,对所有role*的index有所有权限,对cluster有monitor权限,能够登陆和使用kibana
使用这个账户重新登录kibana进行测试

4. script的使用题型

文档的数据是

PUT hamlet02/_bulk
{"index":{"_id":0}}
{"line_number":"1","speaker":"BERNARDO","text_entry":"Whos there?"}
{"index":{"_id":1}}
{"line_number":"2","speaker":"FRANCISCO","text_entry":"Nay, answer me:stand ","reindexBatch":1}

下面这样的
编写一个script,name是control_reindex_batch,用来对hamlet02进行update,如果原文档中有reindexBatch的话,reindexBatch的值会add update的时候传进来的increment参数。如果原文档没有reindexBatch字段的话,就直接初始化为传进来的init参数,同时将speak重命名为leader。

5. search template 使用方式

对于kibana_sample_data_logs中的数据
编写一个search_template name是with_response_and_tag,有三个参数
with_min_response,with_max_response,with_tag
对应的query满足 with_min_response<=response<=with_max_response
tags contains with_tag value

再来一个复杂点的,夹带条件判断,如果
(i) if the “with_max_response” parameter is not set, then don’t set an upper bound to the response value

(ii) if the “with_tag” parameter is not set, then do not apply that filter at all

答案

PUT _scripts/with_response_and_tag05
{"script": {"lang": "mustache","source":"""{"query": {"bool": {"must": [{"range": {"response": {"gte": {{with_min_response}}, "lte": {{with_max_response}}}}},{"match": {"tags": "{{with_tag}}"}}]}}}"""}
}
POST _scripts/with_response_and_tag03
{"script": {"lang": "mustache","source": """{"query": {"bool": {"must": [{"range": {"response": {"gte": {{with_min_response}}{{#with_max_response}},"lte": {{with_max_response}}{{/with_max_response}}}}}{{#with_tag}},{"match": {"tags": "{{with_tag}}"}}{{/with_tag}}]}}}
"""}
}

还有就是json化的方式

6. pipeline使用

文档是数据是这个样子的

POST hamlet-2/_doc/4
{"text_entry": "With turbulent and dangerous lunacy?","line_number": "3.1.4","number_act": "3","speaker": "KING CLAUDIUS","date":"09/12/2020"
}

写一个pipeline叫split_act_scene_line,将line_number使用点号"."切分成三个字段number_act, number_scenenumber_line

这个挂一个答案吧,自己写写试试哦

POST _ingest/pipeline/_simulate
{"pipeline": {"description": "string split by dot","processors": [{"split": {"field": "line_number","separator": "\\.","target_field":"temp_arry"}},{"script": {"lang": "painless","source": """ctx.number_act=ctx.temp_arry[0];ctx.number_scene=ctx.temp_arry[1];ctx.number_line=ctx.temp_arry[2];
"""}},{"remove": {"field": "temp_arry"}}]},"docs": [{"_source": {"line_number": "1.1.3","text_entry": "Long live the king!","reindexBatch": 2,"speaker": "BERNARDO"}}]
}

7. index filter的使用场景

部署三个节点的ES节点,有一个属性叫warm_hot
node01为hot,node02和node03是warm节点。
创建两个索引task701,task702,两个索引都是2个shard。一个shard都存在hot一个都存在warm当中。

第二题
三个节点有一个属性area
node01,node02为rack01, node03为rack02

创建一个索引task703,2个shard,1个replica,
让task703的所有shard能够实现在rack01,rack02上的互备份。

8. search中的几个组合查询,附加alias

filter fuzzy compound term

9. cross_cluster search

在cluster1中写入如下数据

PUT hamlet/_bulk
{"index":{"_id":0}}
{"line_number":"1","speaker":"BERNARDO","text_entry":"Whos there?"}
{"index":{"_id":1}}
{"line_number":"2","speaker":"FRANCISCO","text_entry":"Nay answer me: stand, and unfold yourself."}
{"index":{"_id":2}}
{"line_number":"3","speaker":"BERNARDO","text_entry":"Long live theking!"}
{"index":{"_id":3}}
{"line_number":"4","speaker":"FRANCISCO","text_entry":"Bernardo?"}
{"index":{"_id":4}}
{"line_number":"5","speaker":"BERNARDO","text_entry":"He."}

在cluster2中写入如下数据

PUT hamlet02/_bulk
{"index":{"_id":0}}
{"line_number":"1","speaker":"BERNARDO","text_entry":"Whos there?"}
{"index":{"_id":1}}
{"line_number":"2","speaker":"FRANCISCO","text_entry":"Nay answer me: stand, and unfold yourself."}
{"index":{"_id":2}}
{"line_number":"3","speaker":"BERNARDO","text_entry":"Long live theking!"}
{"index":{"_id":3}}
{"line_number":"4","speaker":"FRANCISCO","text_entry":"Bernardo?"}
{"index":{"_id":4}}
{"line_number":"5","speaker":"BERNARDO","text_entry":"He."}

在cluster1中同时搜索两个集群中speaker为FRANCISCO 的doc

10. snapshot restore

单节点,写入数据

PUT hamlet02/_bulk
{"index":{"_id":0}}
{"line_number":"1","speaker":"BERNARDO","text_entry":"Whos there?"}
{"index":{"_id":1}}
{"line_number":"2","speaker":"FRANCISCO","text_entry":"Nay answer me: stand, and unfold yourself."}
{"index":{"_id":2}}
{"line_number":"3","speaker":"BERNARDO","text_entry":"Long live theking!"}
{"index":{"_id":3}}
{"line_number":"4","speaker":"FRANCISCO","text_entry":"Bernardo?"}
{"index":{"_id":4}}
{"line_number":"5","speaker":"BERNARDO","text_entry":"He."}

shared file system repository可以放在home/repo,home/my_repo 两个目录下
在home/my_repo下创建back_repo的repository,然后对hamlet02 进行备份,备份名称为hamlet_backup

删除hamlet02 验证一下是否能正常恢复(这个要注意可以先做一个reindex保命。。。)

11. dynaic_maping and template

创建一个template,要求

  1. number_开头的string类型会设置为int
  2. 其他类型的string设置为keyword
  3. text_entry字段分别使用standard,english,dutch analyzer
  4. 日期格式为"MM/dd/yyyy"
  5. 所有hamlet开头的索引都会使用这个pattern

测试写入

POST hamlet-2/_doc/4
{"text_entry": "With turbulent and dangerous lunacy?","line_number": "3.1.4","number_act": "3","speaker": "KING CLAUDIUS","date":"09/12/2020"
}

12. join mapping

这篇关于09.需要加强练习的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1124331

相关文章

关于数据埋点,你需要了解这些基本知识

产品汪每天都在和数据打交道,你知道数据来自哪里吗? 移动app端内的用户行为数据大多来自埋点,了解一些埋点知识,能和数据分析师、技术侃大山,参与到前期的数据采集,更重要是让最终的埋点数据能为我所用,否则可怜巴巴等上几个月是常有的事。   埋点类型 根据埋点方式,可以区分为: 手动埋点半自动埋点全自动埋点 秉承“任何事物都有两面性”的道理:自动程度高的,能解决通用统计,便于统一化管理,但个性化定

业务中14个需要进行A/B测试的时刻[信息图]

在本指南中,我们将全面了解有关 A/B测试 的所有内容。 我们将介绍不同类型的A/B测试,如何有效地规划和启动测试,如何评估测试是否成功,您应该关注哪些指标,多年来我们发现的常见错误等等。 什么是A/B测试? A/B测试(有时称为“分割测试”)是一种实验类型,其中您创建两种或多种内容变体——如登录页面、电子邮件或广告——并将它们显示给不同的受众群体,以查看哪一种效果最好。 本质上,A/B测

RabbitMQ练习(AMQP 0-9-1 Overview)

1、What is AMQP 0-9-1 AMQP 0-9-1(高级消息队列协议)是一种网络协议,它允许遵从该协议的客户端(Publisher或者Consumer)应用程序与遵从该协议的消息中间件代理(Broker,如RabbitMQ)进行通信。 AMQP 0-9-1模型的核心概念包括消息发布者(producers/publisher)、消息(messages)、交换机(exchanges)、

Java第二阶段---09类和对象---第三节 构造方法

第三节 构造方法 1.概念 构造方法是一种特殊的方法,主要用于创建对象以及完成对象的属性初始化操作。构造方法不能被对象调用。 2.语法 //[]中内容可有可无 访问修饰符 类名([参数列表]){ } 3.示例 public class Car {     //车特征(属性)     public String name;//车名   可以直接拿来用 说明它有初始值     pu

【Rust练习】12.枚举

练习题来自:https://practice-zh.course.rs/compound-types/enum.html 1 // 修复错误enum Number {Zero,One,Two,}enum Number1 {Zero = 0,One,Two,}// C语言风格的枚举定义enum Number2 {Zero = 0.0,One = 1.0,Two = 2.0,}fn m

MySql 事务练习

事务(transaction) -- 事务 transaction-- 事务是一组操作的集合,是一个不可分割的工作单位,事务会将所有的操作作为一个整体一起向系统提交或撤销请求-- 事务的操作要么同时成功,要么同时失败-- MySql的事务默认是自动提交的,当执行一个DML语句,MySql会立即自动隐式提交事务-- 常见案例:银行转账-- 逻辑:A给B转账1000:1.查询

html css jquery选项卡 代码练习小项目

在学习 html 和 css jquery 结合使用的时候 做好是能尝试做一些简单的小功能,来提高自己的 逻辑能力,熟悉代码的编写语法 下面分享一段代码 使用html css jquery选项卡 代码练习 <div class="box"><dl class="tab"><dd class="active">手机</dd><dd>家电</dd><dd>服装</dd><dd>数码</dd><dd

Science|癌症中三级淋巴结构的免疫调节作用与治疗潜力|顶刊精析·24-09-08

小罗碎碎念 Science文献精析 今天精析的这一篇综述,于2022-01-07发表于Science,主要讨论了癌症中的三级淋巴结构(Tertiary Lymphoid Structures, TLS)及其在肿瘤免疫反应中的作用。 作者类型作者姓名单位名称(中文)通讯作者介绍第一作者Ton N. Schumacher荷兰癌症研究所通讯作者之一通讯作者Daniela S. Thomm

014.Python爬虫系列_解析练习

我 的 个 人 主 页:👉👉 失心疯的个人主页 👈👈 入 门 教 程 推 荐 :👉👉 Python零基础入门教程合集 👈👈 虚 拟 环 境 搭 建 :👉👉 Python项目虚拟环境(超详细讲解) 👈👈 PyQt5 系 列 教 程:👉👉 Python GUI(PyQt5)文章合集 👈👈 Oracle数据库教程:👉👉 Oracle数据库文章合集 👈👈 优

09 生命周期

生命周期 beforeCreatecreatedbeforeMountmountedbeforeUpdateupdatedbeforeDestorydestoryed 辣子鸡:香辣入口,犹如吃了炫迈一样 - - - 根本停不下来 <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport"