Insert & Delete Data - Steps

Steps to delete the records:

Refer to the sample below to delete the data for the month of July module-wise in the Postgres database:

delete from nss_ingest_data where dataKey like '%-07-2022:FIRE%';

delete from nss_ingest_data where dataKey like '%-07-2022:TL%';

delete from nss_ingest_data where dataKey like '%-07-2022:WS%';

delete from nss_ingest_data where dataKey like '%-07-2022:PGR%';

delete from nss_ingest_data where dataKey like '%-07-2022:PT%';

delete from nss_ingest_data where dataKey like '%-07-2022:MCOLLECT%';

Steps to delete the records from ES:

Adjust the module and the date range accordingly.

Check the records before deleting.

Note: Deleting data from both ES and Postgres is mandated to avoid duplication of data.

GET firenoc-national-dashboard/_search
{
  "query": {
    "bool": {
      "must": [
      {
          "range": {
            "date": {
              "gte": 1656613800000,
              "lte": 1658773799000,
              "format": "epoch_millis"
            }
          }
        }
      ]
    }
  }
}

POST firenoc-national-dashboard/_delete_by_query
{
  "query": {
    "bool": {
      "must": [
      {
          "range": {
            "date": {
              "gte": 1656613800000,
              "lte": 1658773799000,
              "format": "epoch_millis"
            }
          }
        }
      ]
    }
  }
}

Last updated

All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.