ElasticSearch6.X query dsl 样例

范围过滤:

GET index_name/type_name/_search
{
  "query": {
    "bool": {
      "filter": {
        "geo_bounding_box": {
          "location": {
            "top_left": {
              "lat": 20.3,
              "lon": 107.5
            },
            "bottom_right": {
              "lat": 17.5,
              "lon": 112
            }
          }
        }
      }
    }
  }
}

Id+时间段:

GET index_name/type_name/_search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "shipId": 11248293
        }
      },
      "filter": {
        "range": {
          "utc": {
            "gte": 1544639907,
            "lte": 1544839907
          }
        }
      }
    }
  }
}

Id+时间段+范围:

GET index_name/type_name/_search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "shipId": 11248293
        }
      },
      "filter": [
        {
          "range": {
            "utc": {
              "gte": 1544639907,
              "lte": 1544839907
            }
          }
        },
        {
          "geo_bounding_box": {
            "location": {
              "top_left": {
                "lat": 20.3,
                "lon": 107.5
              },
              "bottom_right": {
                "lat": 17.5,
                "lon": 112
              }
            }
          }
        }
      ]
    }
  }
}

单列存储时按列返回加上条件过滤:

GET index_name/type_name/_search
{
  "stored_fields" : ["mmsi", "shipId"],
  "query": {
    "bool": {
      "must": {
        "match": {
          "data_source": "04"
        }
      }
    }
  }
}

猜你喜欢

转载自blog.csdn.net/microGP/article/details/86688791