常用的dsl查询语句

{
    "size":0,
    "query":{
        "bool":{
            "must":[
                {
                    "term":{
                        "level_1":{
                            "value":1,
                            "boost":1
                        }
                    }
                },
                {
                    "range":{
                        "deadline":{
                            "from":null,
                            "to":1543981266564,
                            "include_lower":true,
                            "include_upper":false,
                            "boost":1
                        }
                    }
                }
            ],
            "must_not":[
                {
                    "term":{
                        "statusId":{
                            "value":2,
                            "boost":1
                        }
                    }
                }
            ],
            "disable_coord":false,
            "adjust_pure_negative":true,
            "boost":1
        }
    },
    "aggregations":{
        "total_count":{
            "terms":{
                "field":"level_2.keyword",
                "missing":"-1",
                "size":500,
                "min_doc_count":1,
                "shard_min_doc_count":0,
                "show_term_doc_count_error":false,
                "order":[
                    {
                        "_term":"desc"
                    }
                ]
            },
            "aggregations":{
                "timeout_bucket":{
                    "range":{
                        "field":"deadline",
                        "ranges":[
                            {
                                "key":"-1",
                                "from":1543979466564,
                                "to":1543981266564
                            },
                            {
                                "key":"1",
                                "from":1543977666564,
                                "to":1543979466564
                            },
                            {
                                "key":"2",
                                "from":1543975866564,
                                "to":1543977666564
                            },
                            {
                                "key":"3",
                                "from":1543972266564,
                                "to":1543975866564
                            },
                            {
                                "key":"4",
                                "from":1543965066564,
                                "to":1543972266564
                            },
                            {
                                "key":"5",
                                "from":1543957866564,
                                "to":1543965066564
                            },
                            {
                                "key":"6",
                                "from":1543950666564,
                                "to":1543957866564
                            },
                            {
                                "key":"7",
                                "from":1543936266564,
                                "to":1543950666564
                            },
                            {
                                "key":"8",
                                "from":1543893066564,
                                "to":1543936266564
                            },
                            {
                                "key":"9",
                                "from":1543806666564,
                                "to":1543893066564
                            },
                            {
                                "key":"10",
                                "from":1543720266564,
                                "to":1543806666564
                            },
                            {
                                "key":"11",
                                "from":0,
                                "to":1543720266564
                            }
                        ],
                        "keyed":false
                    }
                }
            }
        }
    }
}
{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must": [
                    {
                      "term": {
                        "businessId": {
                          "value": 3,
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "disable_coord": false,
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "term": {
                        "businessId": {
                          "value": 40,
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "disable_coord": false,
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "term": {
                        "businessId": {
                          "value": 6,
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "disable_coord": false,
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              }
            ],
            "disable_coord": false,
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "statusId": {
              "value": 2,
              "boost": 1
            }
          }
        },
        {
          "exists": {
            "field": "ownerId",
            "boost": 1
          }
        }
      ],
      "disable_coord": false,
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "aggregations": {
    "total_count": {
      "terms": {
        "field": "statusId",
        "size": 500,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_term": "asc"
          }
        ]
      }
    }
  }
}
    

 

你可能感兴趣的:(Elasticsearch)