复合查询

复合查询

  • 将多个基本查询组合成单一查询的查询

    GET /lib2/user/_search
    {
       "query":{
           "bool":{
               "must":{
                   "match":{"interests":"唱歌"}
              },
               "must_not":{
                   "match":{"interests":"旅游"}
              },
               "should":[
                  {"match":{"adress":"bei jing"}}
              ],
               "filter":{
                   "range":{"birthday":{"gte":"1996-01-01"}}
              }
          }
      }
    }
  • constant_score查询:它将一个不变的常量评分应用于所有匹配的文档。它被经常用于你需要执行一个filter而没有其他查询(例如,评分查询)的情况下。

    GET /lib2/user/_search
    {
     "query": {
       "constant_score": {
         "filter": {
           "term": {
             "interests": "唱歌"
          }
        }
      }
    }
    }
原文地址:https://www.cnblogs.com/zxbdboke/p/10465793.html