一、题目
编写一个名为 a_data_stream 数据流满足以下请求:
- 数据流索引主分片数为 1 ,副本为 2
 - 数据流索引指定相应的 mapping ,二个字段为 
keyword类型,一个字段为text类型并指定分词器为standard。 
按照上述要求建立数据流
1.1 考点
仔细看题,似乎并不需要索引模板,但是我在官网没找到不适用模板就建立数据流的方法
1.2 答案
            
            
              rust
              
              
            
          
          PUT _index_template/my_template
{
  "index_patterns": ["a_data_stream*"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 2
    },
    "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": {
        "a": {
          "type": "keyword"
        },
        "b": {
          "type": "keyword"
        },
        "c": {
          "type": "text",
          "analyzer": "standard"
        }
      }
    }
  },
  "priority": 500,
  "data_stream": { }
}
PUT _data_stream/a_data_stream
        二、题目
在集群上有一个索引 task1,编写一个查询并满足以下要求:
- 
定义一个名为
a的运行时字段,通过a字段实现以下聚合(a字段的值等于b字段减去c字段) - 
聚合a值小于-2的文档
 - 
聚合-5到5之间的文档
 - 
聚合大于5的文档
 - 
建立测试索引
 
2.1 考点
2.2 答案
            
            
              rust
              
              
            
          
          GET task1/_search
{
  "size": 0, 
  "runtime_mappings": {
    "a": {
      "type": "double",
      "script": {
        "source": """emit(doc['b'].value - doc['c'].value)"""
      }
    }
  },
  "aggs": {
    "a_ranges": {
      "range": {
        "field": "a",
        "ranges": [
          { "to": -2 },
          { "from": -5, "to": 5 },
          { "from": 5 }
        ]
      }
    }
  }
}