1

I am trying filter the response city wise. I am not able to understand how to query filter parameters.

I have tried different ways but with no success. This is the response without applying filter. But I want filter it for a particular city.

{
  "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"
}

This is only documentation on how to do filtering.

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

How to form request url for filtering the response?

2

1 Answer 1

3

yes the documentation is very poor, but still out of many trials I got it work like this

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

Sign up to request clarification or add additional context in comments.

6 Comments

How to have multiple queryparams?
@AnshulBansal check here: stackoverflow.com/a/57556943/1844056
@Raghav7890 @swateek How to filter by date field. I tried filter[last_update] = 17-05-2020 but its not working
@ErBharathRam, I haven’t tried it with a date but just a thought, try providing Unix time as value for that last_update.
@ErBharathRam Are you able to filter based on Date? If yes, can you please give me which method worked for you
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.