1.创建模板
PUT _template/template_purchaser_info
{
"order": 1,
"template": "purchaser_invoice_*",
"settings": {
"index": {
"number_of_shards": "6",
"number_of_replicas": "0",
"mapper": {
"dynamic": "false"
}
}
},
"mappings": {
"invoice": {
"properties": {
"id": {
"type": "text"
},
"invoiceType": {
"type": "keyword"
},
"invoiceNo": {
"type": "keyword"
},
"invoiceCode": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"createTime": {
"type": "date",
"format": "date_time"
},
"updateTime": {
"type": "date",
"format": "date_time"
},
"createUserId": {
"type": "keyword"
},
"createUserName": {
"type": "keyword"
}
}
}
},
"aliases": {
"purchaser_invoice_info": {}
}
}
2.基于模板建索引
匹配到映射路径即可
PUT purchaser_invoice_v1
3 给索引添加字段
POST purchaser_invoice_info/_mapping/invoice
{
"properties": {
"customerNo": {
"type": "keyword"
},
"auditStatus": {
"type": "keyword"
}
}
}
4.查看索引mapping
GET purchaser_invoice_info/_mapping
5.dsl查询
GET tax_goods/_search
{
"query": {
"match": {
"taxcodeName": "垃圾清运费"
}
}
}
6.条件删除doc
POST tax_goods/_delete_by_query
{
"query": {
"match": {
"goodsName": "垃圾清运费"
}
7.删除索引
DELETE purchaser_invoice_v1
8.获取所有模板
本文详细介绍如何在Elasticsearch中创建模板、基于模板构建索引、添加字段、查询及维护索引,包括使用DSL进行精确查询和条件删除文档。
1860

被折叠的 条评论
为什么被折叠?



