当前位置: 首页> 游戏> 游戏 > Elasticsearch 认证模拟题 - 13

Elasticsearch 认证模拟题 - 13

时间:2025/7/13 18:04:30来源:https://blog.csdn.net/Wolf_xujie/article/details/139548380 浏览次数:0次

一、题目

集群中有索引 task3,用 oaOAOaoA 查询结构是 4 条,使用 dingding 的查询结果是 1 条。通过 reindex 索引 task3task3_new,能够使 task3_new 满足以下查询条件。

  1. 使用 oaOAOaoA0Adingding 查询都能够返回 6 条结果
    后能够使得使用oa、OA、Oa、oA、0A、dingding都是6条。
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"}
1.1 考点
  1. 分词器
  2. 重建索引
1.2 答案
# 创建索引结构,定义分词器
PUT /task3_new
{"settings": {"index": {"analysis": {"analyzer": {"synonym_analyzer": {"tokenizer": "standard","filter": ["synonym"]}},"filter": {"synonym": {"type": "synonym","synonyms": ["oa, OA, Oa, oA, 0A, dingding"]}}}}},"mappings": {"properties": {"title":{"type": "text", "analyzer": "synonym_analyzer"}}}
}# 重建索引
POST _reindex
{"source": {"index": "task3"},"dest": {"index": "task3_new"}
}# 验证结果
GET task3_new/_search
{"query": {"match": {"title": "dingding"}}
}

二、题目

集群上有索引 task9 编写一个查询,并满足以下要求:

  1. abc 字段至少有两个字段匹配中 test 关键字
  2. 对查询结果进行排序,先按照 a 字段进行降序排序,再按照 _socre 进行升序排序
  3. a 字段的返回结果高亮显示,前标签是 <h1>,后标签是 </h1>
PUT task9
{"mappings": {"properties": {"a":{"type": "keyword"}}}
}POST task9/_bulk
{"index":{}}
{"a":"test", "b":"b", "c":"test"}
{"index":{}}
{"a":"a", "b":"test", "c":"c"}
{"index":{}}
{"a":"a", "b":"test", "c":"test"}
2.1 考点
  1. Boolean
  2. Sort
  3. Highlighting
2.2 答案
POST task9/_search
{"query": {"bool": {"should": [{"term": {"a": "test"}},{"term": {"b": "test"}},{"term": {"c": "test"}}],"minimum_should_match": 2}},"sort": [{"a": "desc"},{"_score": "asc"}],"highlight": {"fields": {"a": {"pre_tags": ["<h1>"],"post_tags": ["</h1>"]}}}
}

在这里插入图片描述

关键字:Elasticsearch 认证模拟题 - 13

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: