如何使用过滤器选项查询API

时间:2019-06-04 21:38:24

标签: rest api

我正在尝试明智地过滤响应城市。我无法理解如何查询过滤器参数。

我尝试了不同的方法,但没有成功。这是不应用过滤器的响应。但我想针对特定城市进行过滤。

{
  "index_name": "3b01bcb8-0b14-4abf-b6f2-c1bfd384ba69",
  "title": "Real time Air Quality Index from various location",
  "desc": "Real time Air Quality Index from various location",
  "org_type": "Central",
  "org": [
    "Ministry of Environment and Forests",
    "Central Pollution Control Board"
  ],
  "sector": [
    "Industrial Air Pollution"
  ],
  "source": "data.gov.in",
  "catalog_uuid": "a3e7afc6-b799-4ede-b143-8e074b27e0621",
  "visualizable": "1",
  "active": "1",
  "created": 1543320551,
  "updated": 1559683085,
  "created_date": "2018-11-27T17:39:11Z",
  "updated_date": "2019-06-05T02:48:05Z",
  "target_bucket": {
    "index": "air_quality",
    "type": "a3e7afc6-b799-4ede-b143-8e074b27e0621",
    "field": "3b01bcb8-0b14-4abf-b6f2-c1bfd384ba69"
  },
  "field": [
    {
      "id": "id",
      "name": "id",
      "type": "double"
    },
    {
      "id": "country",
      "name": "country",
      "type": "keyword"
    },
    {
      "id": "state",
      "name": "state",
      "type": "keyword"
    },
    {
      "id": "city",
      "name": "city",
      "type": "keyword"
    },
    {
      "id": "station",
      "name": "station",
      "type": "keyword"
    },
    {
      "id": "last_update",
      "name": "last_update",
      "type": "date"
    },
    {
      "id": "pollutant_id",
      "name": "pollutant_id",
      "type": "keyword"
    },
    {
      "id": "pollutant_min",
      "name": "pollutant_min",
      "type": "double"
    },
    {
      "id": "pollutant_max",
      "name": "pollutant_max",
      "type": "double"
    },
    {
      "id": "pollutant_avg",
      "name": "pollutant_avg",
      "type": "double"
    },
    {
      "id": "pollutant_unit",
      "name": "pollutant_unit",
      "type": "keyword"
    }
  ],
  "status": "ok",
  "message": "Resource detail",
  "total": 1000,
  "count": 10,
  "limit": "10",
  "offset": "8",
  "records": [
    {
      "id": "13",
      "country": "India",
      "state": "Andhra_Pradesh",
      "city": "Rajamahendravaram",
      "station": "Anand Kala Kshetram, Rajamahendravaram - APPCB",
      "last_update": "05-06-2019 02:00:00",
      "pollutant_id": "CO",
      "pollutant_min": "2",
      "pollutant_max": "50",
      "pollutant_avg": "28",
      "pollutant_unit": "NA"
    },
    {
      "id": "14",
      "country": "India",
      "state": "Andhra_Pradesh",
      "city": "Rajamahendravaram",
      "station": "Anand Kala Kshetram, Rajamahendravaram - APPCB",
      "last_update": "05-06-2019 02:00:00",
      "pollutant_id": "OZONE",
      "pollutant_min": "37",
      "pollutant_max": "132",
      "pollutant_avg": "71",
      "pollutant_unit": "NA"
    }
    {
      "id": "16",
      "country": "India",
      "state": "Andhra_Pradesh",
      "city": "Tirupati",
      "station": "Tirumala, Tirupati - APPCB",
      "last_update": "05-06-2019 02:00:00",
      "pollutant_id": "PM10",
      "pollutant_min": "33",
      "pollutant_max": "72",
      "pollutant_avg": "55",
      "pollutant_unit": "NA"
    }
  ],
  "version": "2.1.0"
}

这只是有关如何进行过滤的文档。

properties: OrderedMap { "id": OrderedMap { "type": "integer" }, "date": OrderedMap { "type": "integer" } }

如何形成用于过滤响应的请求网址?

1 个答案:

答案 0 :(得分:1)

是的,文档非常差,但是在许多试验中,我还是觉得它像  这个

https://api.data.gov.in/resource/3b01bcb8-0b14-4abf-b6f2-c1bfd384ba69?api-key=<your key>&format=json&offset=0&limit=10 &filters[pollutant_id]=NO2