ES 查询

ES 查询,第1张

ES 查询 查询
GET /trademark_us_index/_search
{
  "query": {
    
          "match": {
            "brandName": {
              "query": "ssssss"
            }
          }
    
  }
}


//第二种写法
GET /trademark_us_index/_search
{
  "query": {
    "bool":{
      "should":[
        {
          "match": {
            "name": {
              "query": "ssssss"
            }
          }
        }
      ],
      "minimum_should_match": "50%"
    }
  }
}
精确查询 + 聚合
GET /trademark_us_index/_search
{
  "query": {
      "match": {
         "name": {
            "query": "ssssss"
         }
    }
  },
  "aggs":{
      "type_count":{
          "terms":{
              "field":"type",
              "size":10000
          }
      },
      "type_count1":{
          "terms":{
              "field":"type",
              "size":10000
          }
      }
    }
}

//第二种写法
GET /trademark_us_index/_search
{
  "query": {
    "bool":{
      "should":[
        {
          "match": {
            "name": {
              "query": "ssssss"
            }
          }
        }
      ],
      "minimum_should_match": "50%"
    }
  },
  "aggs":{
      "type_count":{
          "terms":{
              "field":"type",
              "size":10000
          }
      },
      "type_count1":{
          "terms":{
              "field":"type",
              "size":10000
          }
      }
    }
}
模糊查询 + 精确查询 + 聚合统计
GET /trademark_us_index/_search
{
  "query": {
    "bool":{
      "should":[
        {
          "match": {
            "name": {
              "query": "ssssss"
            }
          }
        },
        {
          "match":{
            "name": {
            "query": "ssssss",
            "fuzziness": "AUTO",
            "prefix_length": 0,
            "max_expansions": 50
            }
          }
        }
      ],
      "minimum_should_match": "50%"
    }
  },
  "aggs":{
      "type_count":{
          "terms":{
              "field":"type",
              "size":10000
          }
      },
      "type_count1":{
          "terms":{
              "field":"type",
              "size":10000
          }
      }
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5702108.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存