Elasticsearch 认证模拟题 - 12

一、题目

在集群上有 task2 索引,请重建它到 task2_new 索引上,并满足以下要求:

  1. task2 索引的 a 字段包含有关键字 Yoo-HooYooHoo ,不管搜索 Yoo-Hoo 还是YooHoo 它们的结果应该一样
  2. task2_newtask2mapping 应该一样
rust 复制代码
POST task2/_bulk
{"index":{}}
{"a":"Yoo-Hoo"}
{"index":{}}
{"a":"YooHoo"}
1.1 考点
  1. 分词器
1.2 答案
rust 复制代码
# 创建索引结构,自定义分词器
PUT task2_new
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_custom_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "char_filter": ["remove-"],
          "filter": []
        }
      },
      "char_filter": {
          "remove-": {
            "type": "mapping",
            "mappings": [
              "- => "
            ]
          }
        }
    }
  },
  "mappings": {
    "properties": {
      "a":{
        "type": "text",
        "analyzer": "my_custom_analyzer"
      }
    }
  }
}

# 写入数据
POST task2_new/_bulk
{"index":{}}
{"a":"Yoo-Hoo"}
{"index":{}}
{"a":"YooHoo"}

# 验证结果
GET task2_new/_search
{
  "query": {
    "match": {
      "a": "YooHoo"
    }
  }
}
GET task2_new/_search
{
  "query": {
    "match": {
      "a": "Yoo-Hoo"
    }
  }
}

二、题目

earthquakes 索引中包含了过去11个月的地震信息,请通过一句查询,获取以下信息

  1. 过去11个月,每个月的平均地震等级(magnitude)
  2. 过去11个月里,平均地震等级最高的一个月及其平均地震等级
  3. 搜索不能返回任何文档
rust 复制代码
# 创建索引
PUT earthquakes
{
  "settings": {
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss"
      },
      "magnitude": {
        "type": "float"
      }
    }
  }
}

# 导入数据
POST earthquakes/_bulk
{"index":{}}
{"timestamp":"2012-01-01 12:12:12", "magnitude":4.56}
{"index":{}}
{"timestamp":"2012-01-01 15:12:12", "magnitude":6.46}
{"index":{}}
{"timestamp":"2012-02-02 13:12:12", "magnitude":4}
{"index":{}}
{"timestamp":"2012-03-02 13:12:12", "magnitude":6}
{"index":{}}
{"timestamp":"1967-03-02 13:12:12", "magnitude":6}
2.1 考点
  1. 分桶聚类
  2. 指标聚类
  3. 管道聚类
2.2 答案
rust 复制代码
POST earthquakes/_search
{
  "size": 0,
  "aggs": {
    "every_month": {
      "date_histogram": {
        "field": "timestamp",
        "calendar_interval": "month",
        "format": "yyyy-MM-dd"
      },
      "aggs": {
        "avg_magnitude": {
          "avg": {
            "field": "magnitude"
          }
        }
      }
    },
    "max_magnitude": {
      "max_bucket": {
        "buckets_path": "every_month>avg_magnitude" 
      }
    }
  }
}
相关推荐
白鲸开源17 小时前
小白指南:Apache DolphinScheduler 补数据功能实操演示
大数据·数据分析·开源
北邮-吴怀玉17 小时前
5.1.5 大数据方法论与实践指南-数据仓库存储格式选择
大数据·数据仓库
派可数据BI可视化17 小时前
数字化转型迫在眉睫,企业应该如何面对?
大数据·数据仓库·信息可视化·数据挖掘·数据分析
电商API_1800790524717 小时前
微店常用API:获取商品详情接口|关键字搜索商品接口|获取快递费接口-打通商品运营与用户体验的技术桥梁
大数据·服务器·人工智能·爬虫·数据挖掘
海豚调度17 小时前
小白指南:Apache DolphinScheduler 补数据功能实操演示
大数据·开源·任务调度·开源社区·大数据调度·apachedolphinscheduler
R.lin18 小时前
使用注解将日志存入Elasticsearch
java·大数据·后端·elasticsearch·中间件
安卓开发者19 小时前
Docker 安装和配置 Elasticsearch 完整指南
elasticsearch·docker·容器
北邮-吴怀玉19 小时前
5.2 大数据方法论与实践指南-存储元数据治理
大数据·数据治理·元数据
Giser探索家19 小时前
无人机数字资产采集技术架构与实践:从多维度感知到云端化建模的实现路径
大数据·人工智能·算法·计算机视觉·分类·无人机
人大博士的交易之路20 小时前
龙虎榜——20251028
大数据·数据挖掘·数据分析·缠论·龙虎榜·道琼斯结构