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

相关推荐
远方160913 小时前
115-使用freesql体验Oracle 多版本特性
大数据·数据库·sql·ai·oracle·database
happymaker062613 小时前
JDBC(MySQL)——DAY01
数据库·mysql
qqacj13 小时前
MSSQL2022的一个错误:未在本地计算机上注册“Microsoft.ACE.OLEDB.16.0”提供程序
数据库·microsoft
ren0491813 小时前
MySQL
数据库·mysql
良逍Ai出海13 小时前
OpenClaw 新手最该先搞懂的 2 套命令
android·java·数据库
Keanu-13 小时前
Redis 主从复制及哨兵模式配置
服务器·数据库·redis
blues925713 小时前
【JOIN】关键字在MySql中的详细使用
数据库·mysql
x-cmd14 小时前
[260307] x-cmd v0.8.6:新增 gpt-5.4 模型支持,sudo/os/hostname/cpu 等模块文档更新
java·数据库·gpt·sudo·x-cmd·googel
JuneXcy14 小时前
第10章 数据库的安全与保护
数据库·mysql
YDS82914 小时前
SpringCloud —— Elasticsearch的DSL查询
java·elasticsearch·搜索引擎·spring cloud