es部分请求语句
1、根据文档id更新
POST sys_score_much_index_49_202206/_doc/506499385/_update
{
"doc": {
"is_issue": 0
}
}
2、根据条件更新
POST sys_score_much_index_49_202206/_doc/_update_by_query
{
"query": {
"match": {
"contact_id": "2022061712242692642637S1"
}
},
"script": {
"source": "ctx._source['is_issue']=0"
}
}
POST sys_score_much_index_49_202206/_doc/_update_by_query
{
"query": {
"term": {
"plan_id": 12955
}
},
"script": {
"source": "ctx._source['is_issue']=0"
}
}
3、查询某个字段不为空
{
"query": {
"exists": {
"field": "human_plan_span"
}
}
}
4.es索引创建模板(GET _template/sys_asr_log_template(get查看,put创建))
PUT _template/sys_asr_log_template
{
"order": 3,
"index_patterns": [
"vic_asr_log_*"
],
"settings": {
"index": {
"number_of_shards": "3",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"asrTime": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"contactId": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"asrText": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 7000,
"type": "keyword"
}
}
},
"asrJson": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"asrDateTime": {
"type": "long"
}
}
},
"aliases": {
}
}
5.es修改索引属性(ignore_above)(原ignore_above为256,现修改为7000,极限8000(网上查询))
PUT sys_asr_log_202403/_mappings
{
"properties": {
"asrText": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 7000,
"type": "keyword"
}
}
}
}
}
6.es新增数据
POST http://10.125.128.187:3888/sys_asr_log_202303/_doc
{
"name":"张三"
}
7.正则查询
GET http://192.168.1.1:8080/index_name/_search
{
"query": {
"regexp": {
"contactId": "20230301..3[4-5].+"
}
}
}
8.es删除索引(此处的索引名存在特殊字符,需要进行url编码转义,才可删除成功)(正常删除,直接指定索引名即可)
http://192.168.1.1:8080/
user_index_%25%7Bsharding_id%7d_%25%7Bmonth_id%7d DELETE
9.es根据id删除数据
索引名/_doc/文档id DELETE