一、题目
生成快照,或快照生命周期
1.1 考点
(因为这个需要部署共享文件,所以这个我就在虚拟机上简单操作一下)
注: 部署共享文件系统可以看这个文章:NFS 文件共享服务器
1.2 答案
rust
# 创建仓库
PUT _snapshot/fs_backup
{
"type": "fs",
"settings": {
"location": "/data/NFS/test"
}
}
# 创建快照
PUT /_snapshot/fs_backup/snapshot_1?wait_for_completion=true
{
"indices": "kibana_sample_data_ecommerce",
"ignore_unavailable": true,
"include_global_state": false
}
二、题目
定义一个搜索模板,查询 fielda
字段,然后对 fielda
字段用标签高亮,然后按 fieldb
倒排,然后用这个模板去查询索引
rust
# 创建符合条件的 task 索引,设置 field 字段,并写入数据
PUT task
{
"mappings": {
"properties": {
"fielda":{
"type": "text"
},
"fieldb":{
"type": "long"
}
}
}
}
# 写入数据
POST task/_bulk
{"index":{}}
{"fielda":"中国人民广场","fieldb": 5}
{"index":{}}
{"fielda":"中华人民共和国万岁","fieldb": 6}
{"index":{}}
{"fielda":"山上山下红旗飘飘","fieldb": 4}
{"index":{}}
{"fielda":"中国共产党万岁","fieldb": 5}
2.1 考点
2.2 答案
rust
# 创建搜索模板
PUT _scripts/search-template
{
"script": {
"lang": "mustache",
"source": {
"query": {
"match": {
"fielda": "{{query_string}}"
}
},
"highlight": {
"fields": {
"fielda": {
"pre_tags": [
"<em>"
],
"post_tags": [
"</em>"
]
}
}
},
"sort": [
{
"fieldb": {
"order": "desc"
}
}
],
"from": "{{from}}",
"size": "{{size}}"
},
"params": {
"query_string": "My query string"
}
}
}
# 预览搜索模板
POST _render/template
{
"id": "search-template",
"params": {
"query_string": "万岁",
"from": 0,
"size": 2
}
}
# 使用搜索模板搜索
GET task/_search/template
{
"id": "search-template",
"params": {
"query_string": "万岁",
"from": 0,
"size": 2
}
}