1. runtime fields+range aggs

    ● 在cluster1上有一task1索引,请编写一个查询并满足以下要求:
    ● 定义一个名为a的运行时字段,通过a字段实现以下聚合(a字段的值等于b字段减去c字段)
    ● 聚合a值小于-2的文档
    ● 聚合-5到5之间的文档
    ● 聚合大于5的文档
    ● 建立测试索引


PUT task1
{"settings": {"number_of_replicas": 0,"number_of_shards": 1},"mappings": {"properties": {"b": {"type": "long"},"c": {"type": "long"}}}
}POST task1/_bulk
{"index":{"_id":1}}
{"b":5,"c":6}
{"index":{"_id":2}}
{"b":5,"c":1}
{"index":{"_id":3}}
{"b":8,"c":1}
{"index":{"_id":4}}
{"b":5,"c":8}PUT task1/_mapping
{"runtime": {"a": {"type": "long","script": {"source": "emit(doc['b'].value - doc['c'].value)"}}}
}POST /task1/_search
{"size": 0, "aggs": {"agga": {"range": {"field": "a","ranges": [{"to": -2},{"from": -5,"to":5},{"from": 5}]}}}
}
  1. analyzer+reindex

    ● 在集群一上有task2索引,请重建它到task2_new索引上,并满足以下要求:
    ● 集群一的a字段包含有关键字’yoo-hoo’和’yoohoo’,不管搜索’yoohoo’还是’yoo-hoo’,它们的结果应该一样
    ● task2_new和task2的mapping应该一样
    ● 知识点:自定义分词、reindex


PUT task4-2
{"settings": {"number_of_replicas": 0,"number_of_shards": 1},"mappings": {"properties": {"title":{"type": "text"}}}
}
POST task4-2/_doc/1
{"title":"yoo-hoo"}
POST task4-2/_doc/2
{"title":"yoohoo"}

PUT task2_new
{"settings": {"number_of_replicas": 0,"number_of_shards": 1,"analysis": {"analyzer": {"my_analyzer":{"tokenizer":"my_tokenizer","filter":"my_filter"}},"tokenizer": {"my_tokenizer":{"type":"standard"}},"filter": {"my_filter":{"type":"synonym","synonyms": [ "yoo-hoo => yoohoo" ]}}}},"mappings": {"properties": {"title":{"type": "text","analyzer": "my_analyzer"}}}
}POST /_reindex
{"source": {"index": "task4-2"},"dest": {"index": "task2_new"}
}GET task2_new/_search
{"query": {"match": {"title": "yoohoo"}}
}
  1. 数据流+索引生命周期管理
    现有以下文档,请编写一个名为test_data_stream数据流满足以下请求:

    {"@timestamp": "2099-03-08T11:04:05.000Z","message": "test"
    }
    

    ● 数据流索引的主分片数为3,副本分片数为1
    ● 将上述文档填充到数据流中去

Data streams

index-templates

PUT _component_template/my_comp_temp
{"template": {"settings": {"number_of_replicas": 1,"number_of_shards": 1},"mappings": {"properties": {"@timestamp":{"type": "date"},"message":{"type":"text"}}}}
}PUT _index_template/my_index_temp
{"index_patterns": ["test_data_stream*"],"data_stream":{},"composed_of":["my_comp_temp"]
}POST test_data_stream/_doc/1?op_type=create
{"@timestamp": "2099-03-08T11:04:05.000Z", "message": "test"}
  1. 跨集群复制,Cross-Cluster Replication
    ● 远程集群,remote cluster leader 192.168.0.11:9300, kibana:192.168.0.11:5601 主集群
    ● 本地集群,local cluster follower 192.168.0.14:9300, kibana:192.168.0.14:5601 备份集群

在本地集群192.168.0.14,添加一个远程集群,即主集群的IP和端口 [在192.168.0.14上操作]

PUT /_cluster/settings
{"persistent": {"cluster": {"remote":{"leader":{"seeds":["192.168.0.11:9300"]}}}}
}

使用Kibana图形化界面配置:Stack Management->Data->Cross-Cluster Replication。[在192.168.0.14上操作]

● 在Remote cluster栏:Remote cluster
● 在Leader index栏:employees
● 在Follower index栏:follow_employees
● 点击:create

检测:[在192.168.0.14上操作]

GET /follow_employees/_ccr/stats
GET /follow_employees/_count
  1. 查询模板

    ● 对task5编写一个查询模板,并满足以下要求:
    ● 使用a_01参数查询’a’字段;
    ● 使用start_date和end_date参数范围查询timestamp字段
    ● 如果没有提供end_date字段,那么结束时间默认是现在
    ● 查询结果中b字段必须equals’b’,
    ● 查询2018年6月1日到现在的数据,a字段包含关键字’aaa’

Search your data > Search templates

DELETE task5
PUT task5
{"mappings": {"properties": {"a":{"type": "text"},"b":{"type": "keyword"},"timestamp":{"type": "date"}}}
}POST /task5/_doc/1
{"a":"aaa AAA", "b":"b", "timestamp":"2021-11-11T11:21:21.000Z"}PUT _scripts/my-search-template
{"script": {"lang": "mustache","source": {"query": {"bool": {"must":[{"term":{ "b":"b"}},{"match":{"a":"aaa"}}],"should": [{"term": {"a": "{{a_01}}"}},{"range": {"timestamp": {"gte": "{{start_date}}","lte":"{{end_date}}{{^end_date}}now/d{{/end_date}}"}}}]}}}}
}GET task5/_search/template
{"id": "my-search-template","params": {"a_01": "a","start_date": "2018-06-01"}
}
  1. earthquakes索引中包含了过去11个月的地震信息,请通过一句查询,获取以下信息
    ● 过去11个月,每个月的平均地震等级(magiitude)
    ● 过去11个月里,平均地震等级最高的一个月及其平均地震等级
    ● 搜索不能返回任何文档

Aggregations› Bucket aggregations

当日期是keyword类型时

GET earthquakes/_mapping
PUT earthquakes/_mapping
{"runtime":{"yearmonth":{"type":"keyword","script":{"source":"emit(doc['DateTime'].value.substring(0,7))"}}}
}GET earthquakes/_search
{"size": 0,"aggs": {"bucket_month": {"terms": {"field": "yearmonth"},"aggs": {"avg_Magnitude": {"avg": {"field": "Magnitude"}}}},"max_Magnitude":{"max_bucket": {"buckets_path": "bucket_month>avg_Magnitude"}}}
}

当日期是date类型

DELETE /earthquakes2
PUT earthquakes2
{"settings": {"number_of_replicas": 0},"mappings": {"properties": {"DateTime":{"type": "date","format": "yyyy-MM-dd HH:mm:ss"},"Magnitude":{"type": "float"}}}
}POST earthquakes2/_bulk
{"index":{"_id":1}}
{"DateTime":"2016-01-01 12:12:12", "Magnitude":4.56}
{"index":{"_id":2}}
{"DateTime":"2016-01-01 15:12:12", "Magnitude":6.46}
{"index":{"_id":3}}
{"DateTime":"2016-02-02 13:12:12", "Magnitude":4}
{"index":{"_id":4}}
{"DateTime":"2016-03-02 13:12:12", "Magnitude":6}GET earthquakes2/_search
{"size": 0,"aggs": {"Magnitude_per_month": {"date_histogram": {"field": "DateTime","calendar_interval": "month"},"aggs": {"avg_per_month": {"avg": {"field": "Magnitude"}}}}}
}
  1. 同义词+reindex 等。目前有个索引是task3,用oa、OA、Oa、oA phrase查询是3条,使用dingding的phrase查询是2条,通过reindex 索引后能够使得使用oa、OA、Oa、oA、0A、dingding都是6条。
    ● 准备task3的索引,导入6条不同的文档数据
    ● reindex task3的索引到task3_new后
PUT task3
{"settings": {"number_of_replicas": 0},"mappings": {"properties": {"title": {"type": "text"}}}
}POST task3/_bulk
{"index":{}}
{"title":"oa"}
{"index":{}}
{"title":"OA"}
{"index":{}}
{"title":"Oa"}
{"index":{}}
{"title":"oA"}
{"index":{}}
{"title":"0A"}
{"index":{}}
{"title":"dingding"}DELETE task3_new
PUT task3_new
{"settings": {"analysis": {"analyzer": {"my_analyzer": {"tokenizer": "standard","filter": ["my_filter"]}},"filter": {"my_filter":{"type":"synonym","synonyms":["oa,OA,Oa,oA,0A,dingding"]}}}},"mappings": {"properties": {"title":{"type": "text","analyzer": "my_analyzer"}}}
}POST /_reindex
{"source": {"index": "task3"},"dest": {"index": "task3_new"}
}GET task3_new/_search
{"query": {"match": {"title": "0A"}}
}
  1. 索引 movie-1,保存的电影信息,title是题目,tags是电影的标签,要求:

    ● 在title中包含“my”或者“me”。
    ● 如果在tags中包含"romatic movies",该条算分提高,如果不包含则算分不变

PUT movie-1
{"mappings": {"properties": {"title":{"type": "text"},"tags":{"type": "keyword"}}}
}POST /movie-1/_search
{"query": {"function_score": {"query": {"bool": {"should": [{"match":{"title": "my"}},{"match":{"title": "me"}}]}},"functions": [{"filter":{"term":{"tags":"romatic movies"}},"weight":5}]}}
}
  1. 对集群一上的task9索引编写一个查询,并满足以下要求:
    ● ‘a’,‘b’,‘c’字段至少有两个字段匹配中’test’关键字
    ● 对查询结果进行排序,先按照’a’字段进行降序排序,再按照’_socre’进行升序排序
    ● 'a’字段的返回结果高亮显示,前标签是,后标签是

Query DSL› Compound queries

PUT task9
{"mappings": {"properties": {"a":{"type": "keyword"},"b":{"type": "text"},"c":{"type": "text"}}}
}POST task9/_search
{"query": {"bool": {"should": [{"match": {"a": "test"}},{"match": {"b": "test"}},{"match": {"c": "test"}}],"minimum_should_match": 2}},"sort": [{"a": {"order": "desc"}},{"_score":{"order": "asc"}}],"highlight": {"fields": {"a": {"pre_tags": ["<em>"],"post_tags": ["</em>"]}}}
}

[ECE]模拟试题-4相关推荐

  1. [ECE]模拟试题-6

    在cluster1上有一task1索引,请编写一个查询并满足以下要求: ● 定义一个名为difference的运行时字段,实现以下聚合(a字段的值等于close_field字段减去open_field ...

  2. [ECE]模拟试题-7

    在集群cluster1上有一个索引food_ingredient,搜索满足以下要求: 三个字段manufacturer, name, brand任意能搜索到text "cakemix&quo ...

  3. [ECE]模拟试题-2

    在cluster1上有一task1索引,请编写一个查询并满足以下要求: runtime fields+range aggs. ● 定义一个名为a的运行时字段,通过a字段实现以下聚合(a字段的值等于b字 ...

  4. [ECE]模拟试题-5

    在cluster1上有一task1索引,请编写一个查询并满足以下要求: ● 定义一个名为a的运行时字段,通过a字段实现以下聚合(a字段的值等于b字段减去c字段) ● 聚合a值小于-2的文档 ● 聚合- ...

  5. [ECE]模拟试题-1

    有一个索引task2,有field2字段,用match匹配the能查到很多数据,现在要求对task2索引进行重建,重建后的索引叫new_task2,然后match匹配the查不到数据 Text ana ...

  6. 计算机考试批处理试题,2015计算机三级考试pc技术模拟试题及答案(八)

    2015计算机三级考试pc技术模拟试题及答案(八) 1.关于Windows 98中的网上邻居的相关叙,( )是错误的. A.通过网上邻居可以游览和使用网上的全部计算机资源 B.通过网上邻居可以浏览网上 ...

  7. 微型计算机组成原理考试,全国高等教育自学考试计算机组成原理模拟试题

    第一部分 选择题(共15分) 一.单项选择题(本大题共15小题,每小题1分,共15分.在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内.错选.多选或未选均无分.) 1. ...

  8. 计算机一级在线模拟试题,计算机一级模拟试题带答案

    计算机一级模拟试题带答案 计算机考试分为四个等级,不同等级的内容不同,那么百分网小编为大家提供的是关于计算机一级的模拟考试题,希望能为各位考生的复习提供帮助! 一.判断正误题,正确填A,错误填B(共2 ...

  9. 计算机一级考模拟试题,计算机一级MSOffice考前模拟试题「附答案」

    计算机一级MSOffice考前模拟试题「附答案」 一级分为DOS版和Windows版,考核应试者计算机基本知识和使用微机系统的初步能力.那么计算机一级MSOffice考试会怎么考?以下仅供参考! 1) ...

最新文章

  1. Javascript 节点 全面解析
  2. Java最大的优势真的在于跨平台吗?
  3. 吴恩达:我们说人工智能时,实际在说些什么?
  4. 通过html文件生成PDF文件
  5. 测试如何学python_如何从0开始学Python自动化测试
  6. 肝!2500字 字符串专题总结
  7. java入参为方法_Java命令注入原理结合Java Instrument技术(FreeBuf首发)
  8. shell磁盘监控自动化处理
  9. ASP.NET WebAPi之断点续传下载(上)
  10. Spark Mlib TFIDF源码详读 笔记
  11. 【Android】ListView ViewHolder ArrayIndexOutOfBoundsException: length=2; index=2
  12. [原创]Installshield工具介绍
  13. 文件一键上传、汉字转拼音、excel文件上传下载功能模块的实现
  14. 单页面网站优化技巧有哪些?
  15. TensorFlow安装和下载详细教程-内附多种解决方案
  16. 欧文计算机科学排名,2020年加州大学欧文分校排名TFE Times美国最佳计算机科学硕士专业排名第36...
  17. 关于请求报文和响应报文的详解
  18. nodejs实现ocr
  19. 神仙程序媛小姐姐的一些列Java教程,从小白到进阶,春招和秋招必备的面试题,全站式保姆的Java教程导航帖(未完结)
  20. 平面、3D设计软件最全集子(Windows系32、64位)

热门文章

  1. 卸载vue-cli过程中npm uninstall vue-cli -g 一直显示 up to date in 0.042s无法卸载
  2. 【数据库】某医院病房计算机管理中需要如下信息: 科室:科名、科地址、科电话、医生姓名 病房:病房号、床位号、所属科室名 医生:姓名、职称、所属科室名、年龄、工作证号 病人:病历号、姓名、性别、诊
  3. 消费者太穷不愿买手机?苹果的份额创新高,撕下国产手机遮羞布
  4. 一款开源的协作文本编辑器
  5. 关于1000BASE-T1 1000BASE-TX和100BASE-T1
  6. pytorch股票预测
  7. DHCP如何分配IP地址
  8. 锁机制与原子操作 第四篇
  9. mv或者cp带小括号文件名解析问题总结
  10. 好用的Mac视频下载软件--Downie 4