ES-入门-http-多条件查询&范围查询

must 表示多个条件需要同时满足

在postman 对应的参数配置如下

javascript 复制代码
{
    "query": {
        "bool": {
            "must" : [
                {
                    "match" :{
                        "category":"小米"
                    }
                },
                {
                    "match":{
                          "price":3999.00
                    }
                }
            ]
        }
    }
}

如下图查询的结果是需要同时满足小米和价格为1999的数据。只有一条

上面类似于sql中的and

下面的条件设定为or。

javascript 复制代码
{
    "query": {
        "bool": {
            "should" : [
                {
                    "match" :{
                        "category":"小米"
                    }
                },
                {
                    "match":{
                          "category":"华为"
                    }
                }
            ]
        }
    }
}

范围查询的参数设定

javascript 复制代码
{
    "query": {
        "bool": {
            "should" : [
                {
                    "match" :{
                        "category":"小米"
                    }
                },
                {
                    "match":{
                          "category":"华为"
                    }
                }
            ],
            "filter" : {
                "range": {
                    "price": {
                        "gt" :5000
                    }
                }
            }
        }
    }
}

返回价格大于5000的手机信息

相关推荐
snow@li21 小时前
数据库:市场中都有哪些数据库 / 优缺点 使用情况
数据库
NoSi EFUL1 天前
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
android·数据库·mysql
河阿里1 天前
SQL数据库:五大范式(NF)
数据库·sql·oracle
Elastic 中国社区官方博客1 天前
为 Elastic Cloud Serverless 和 Elasticsearch 引入统一的 API 密钥
大数据·运维·elasticsearch·搜索引擎·云原生·serverless
l1t1 天前
DeepSeek总结的PostgreSQL 19查询提示功能
数据库·postgresql
chenxu98b1 天前
MySQL如何执行.sql 文件:详细教学指南
数据库·mysql
刘晨鑫11 天前
MongoDB数据库应用
数据库·mongodb
vastsmile1 天前
(R)26.04.23 hermes agent执行本地命令超级慢的原因
开发语言·elasticsearch·r语言
梦想的颜色1 天前
mongoTemplate + Java 增删改查基础介绍
数据结构·数据库·mysql
小小小米粒1 天前
redis命令集合
数据库·redis·缓存