1.基本查询
GET /index_name/_search
{
"query": {
"match": {
"dispatchClass": "1"
}
}
}
2.多条件查询
GET /index_name/_search
{
"query": {
"bool": {
"must": [
{"match": {
"createUser": "xxxx"
}},
{
"match": {
"updateUser": "xxxx"
}
}
]
}
}
}
3.范围查询
GET /index_name/_search
{
"query": {
"bool": {
"filter": [
{"range": {
"createTime": {
"gte": "2023-01-01 00:00:00",
"lte": "2023-08-15 20:00:00"
}
}}
]
}
}
}
4.复杂查询
GET /index_name/_search
{
"query": {
"bool": {
"must": [
{"match": {
"createUser": "xxxx"
}},
{
"match": {
"updateUser": "xxxxx"
}
}
]
, "filter": [
{"range": {
"createTime": {
"gte": "2023-01-01 00:00:00",
"lte": "2023-08-15 20:00:00"
}
}}
]
}
}
}
5.聚合查询
GET /index_name/_search
{
"aggs": {
"total_count": {
"value_count": {
"field": "id"
}
}
}
}
文章来源地址https://www.toymoban.com/news/detail-653297.html
文章来源:https://www.toymoban.com/news/detail-653297.html
到了这里,关于常用的Elasticsearch查询DSL的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!