微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

elasticsearch中的布尔查询

elasticsearch中的布尔查询

例如查询年龄是25岁,输入王者荣耀的英雄
GET test1/_search { "query": { "bool": { "must": [ { "match": { "age": "25" } }, { "match": { "location": "王者" } } ] } } }

查询年龄为25或者来自王者荣耀的人物

GET test1/_search { "query": { "bool": { "should": [ { "match": { "age": 25 } }, { "match": { "location.keyword": "王者荣耀" } } ] } } }

查询年龄大于50,且属于魏国的人物。

`GET test1/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"location.keyword": "魏国"
}
}
],
"filter": [
{
"range": {
"age": {
"gt": 50

        }
      }
    }
  ]
}

}
}`

查询的方式方法有以下几种。

查询结构进行过滤

`GET test1/_search
{
"query": {
"match_all": {}
},
"_source": ["location","age"]

}
`

高亮显示,对结果进行高亮显示

GET test1/_search { "query": { "match": { "location": "英雄" } }, "highlight": { "pre_tags": "<b>", "post_tags": "</b>", "fields": { "location": {} } } }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐