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的手机信息

相关推荐
字节跳动开源2 小时前
Viking AI 搜索 CLI 正式发布:会说话,就能做搜索推荐
数据库·人工智能·开源
TechWJ3 小时前
数据库在公司内网,出差路上想查数据怎么办?
服务器·数据库·mariadb
我是一颗柠檬3 小时前
【MySQL全面教学】MySQL事务与ACID Day9(2026年)
数据库·后端·mysql
橙子圆1233 小时前
Redis知识9之集群
数据库·redis·缓存
basketball6163 小时前
HTTP协议返回状态码总结
网络·网络协议·http
BlackHeart12033 小时前
【SQL】Oracle中序列(Sequence)作为默认值引发的ORA-00979
数据库·sql·oracle
bug菌4 小时前
【SpringBoot 3.x 第254节】夯爆了,数据库访问性能优化实战详解!
数据库·spring boot·后端
xxl大卡4 小时前
MySQL的执行流程
数据库·mysql
chicheese4 小时前
MySQL优化实践:选错JOIN 驱动表,性能相差几十倍
数据库·mysql
無限進步D4 小时前
MySQL 单行函数
数据库·mysql