zoukankan      html  css  js  c++  java
  • 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": {} } } }

  • 相关阅读:
    Beta 冲刺 (5/7)
    Beta 冲刺 (4/7)
    Beta 冲刺 (3/7)
    软件产品案例分析(团队)
    Beta 冲刺 (2/7)
    Beta 冲刺 (1/7)
    BETA 版冲刺前准备
    Alpha事后诸葛(团队)
    设计模式——访问者模式
    设计模式——命令模式
  • 原文地址:https://www.cnblogs.com/ch2020/p/15641722.html
Copyright © 2011-2022 走看看