赞
踩
编写一个名为 a_data_stream
数据流满足以下请求:
keyword
类型,一个字段为 text
类型并指定分词器为 standard
。按照上述要求建立数据流
仔细看题,似乎并不需要索引模板,但是我在官网没找到不适用模板就建立数据流的方法
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
,编写一个查询并满足以下要求:
1. 定义一个名为 a
的运行时字段,通过 a
字段实现以下聚合(a
字段的值等于 b
字段减去 c
字段)
2. 聚合a值小于-2的文档
3. 聚合-5到5之间的文档
4. 聚合大于5的文档
5. 建立测试索引
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 }
]
}
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。