es-dsl笔记

查询所有的索引信息
GET /_cat/indices?v

//查询映射关系
GET /index_name/_mapping?pretty=true

查询所有的索引
POST /_xpack/sql?format=txt
{
"query": "SHOW tables"
}

一些简单的sql转换成dsl
GET /_xpack/sql/translate
{
"query":"select * from index_name where xxx=xxx "
}
特殊字符需要转义 "query":"select * from "funmall-gemini-channel-service" "

{
"_source": [
"thumbnailUrl"
],
"query": {
"bool": {
"must": [
{
"bool": {
"must_not": [
{
"exists": {
"field": "thumbnailUrl"
}
}
]
}
}
]
}
},
"script": {
"lang": "painless",
"inline": "ctx._source.thumbnailUrl = params.thumbnailUrl;",
"params": {
"thumbnailUrl": "http://xxxx.qq.com"
}
}
}

select * from xxx where a=xx and (applyScene in(1,2) or cmbMobileApplyScene in (1,3))
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"terms": {
"applyScene": [
"1",
"2"
],
"boost": 1
}
},
{
"terms": {
"cmbMobileApplyScene": [
"1",
"3"
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
{
"terms": {
"shopNo": [
"ST20133"
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
}

posted @ 2020-04-17 11:42  Me无情  阅读(202)  评论(0编辑  收藏  举报