# Inbox v2 & Elastic Search

## Overview

This page outlines the steps required to configure the inbox to enable viewing complaints and indexing the complaint data using **ElasticSearch**.

<table><thead><tr><th width="186.47265625">Service</th><th>Purpose</th></tr></thead><tbody><tr><td><strong>Inbox V2</strong></td><td>UI to display user tasks (e.g., complaints, applications)</td></tr><tr><td><strong>Indexer</strong></td><td>Sends complaints data to ElasticSearch</td></tr><tr><td><strong>ElasticSearch</strong></td><td>Stores indexed data and supports fast search queries</td></tr></tbody></table>

***

The following core components are required for the configuration:

<table><thead><tr><th width="193.94140625">Component</th><th>Purpose</th></tr></thead><tbody><tr><td>Indexer Config</td><td>Maps Kafka data into ElasticSearch (decides what to store)</td></tr><tr><td>MDMS Config</td><td>Defines how Inbox service queries ElasticSearch</td></tr><tr><td>Reindexing</td><td>Used when existing data is missing or out of sync</td></tr></tbody></table>

***

## Configure Indexer & Inbox v2&#x20;

A Kafka message is generated whenever a complaint is raised. The Indexer service reads it and stores data in ElasticSearch, based on this configuration.&#x20;

Configuration parameter details:

<table><thead><tr><th width="177.65625">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>topic</code></td><td>Kafka topic: <code>save-pgr-request</code></td></tr><tr><td><code>index</code></td><td>ElasticSearch index: <code>pgr-services;</code> <code>customJsonMapping:</code></td></tr><tr><td><code>fieldMapping</code></td><td>Maps input JSON to index structure <code>inJsonPath; outJsonPath</code></td></tr></tbody></table>

Follow the steps below to send the Citizen Complaints module data to Elastic Search.

{% stepper %}
{% step %}

### Create file pgr-services.yml&#x20;

Create a file pgr-services.yml inside the given path at the config repo on GitHub

* Create file: egov-indexer/pgr-inbox-indexer.yml&#x20;
* Paste the indexer config into this file: [ Sample Config File for Reference](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/master/configs/egov-indexer/pgr-inbox-indexer.yml)
* Restart the Indexer service so it picks up the new configuration.
  {% endstep %}

{% step %}

### MDMS Configuration for Inbox V2

The MDMS configuration defines how the Inbox V2 module fetches data from ElasticSearch to show complaint details in the UI.

{% hint style="info" %}
Refer to the [Master Data configuration doc](https://docs.digit.org/complaints-management/deploy/configure/master-data) for details. This step is not required if the master data configuration is done.
{% endhint %}

Below are the steps to configure MDMS for Inbox V2 -

**A. Import Postman Collection**

* Open the provided [Postman collection](https://api.postman.com/collections/23418568-482ec4ae-f326-4dff-8c17-f7a5d2be499f?access_key=PMAT-01K091MYQKDM4CWG1VWSNFY5SX).
* Copy the above Postman collection. &#x20;
* Click on the **Import** icon in Postman.
* Paste the URL and import the collection.
* After import, you’ll find the collection on the **left panel** of Postman.
* Before proceeding to the next step, make sure the prerequisites baseUrl and authtoken are updated.

**B. Set Up Postman Environment Variables**

* Make sure your Postman environment has these updated values:
  * baseUrl (e.g., [https://unified-demo.digit.org](https://unified-demo.digit.org/))  (This is the domain URL where your application is running . Need to copy that domain URL here)
  * User Details (Mdsm admin user) (Which was created during the installation . Need to copy username, password, and tenantid of the mdmsAdmin user)
  * tenantId (e.g., pb, uk) (In the  request body, need to verify or update the tenantId where going to set up the master data )
* Add the required variables in the Postman Collection before running the MDMS script. Refer to the table below for details.

<table><thead><tr><th width="190.05859375">Variable Name</th><th>Description</th></tr></thead><tbody><tr><td>Url</td><td><p>The domain URL where your DIGIT application is hosted. Example: https://pgr-demo.digit.org</p><p>📌 Add this in the "URL" variable field.</p></td></tr><tr><td>username</td><td><p>The admin username for MDMS (e.g., mdms admin). Required for authentication.</p><p>📌 Add this in the "username" variable field.</p></td></tr><tr><td>password</td><td><p>The admin password for the above username.</p><p>📌 Add this in the "password" variable field.</p></td></tr><tr><td>tenant</td><td><p>The state-level tenant ID (e.g., pg).</p><p>📌 Add this in the "tenant" variable field.</p></td></tr><tr><td>userTenant</td><td><p>The ULB-level tenant ID where the user has been created (e.g., pg).</p><p>📌 Add this in the "userTenant" variable field.</p></td></tr></tbody></table>

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfgpeTn7UA7yckhNu9jGdGdW6c-wM-9GJoilJozuGGgkCIOEp8HKObH9yObDZhSDc2RAiU6Kn0aDShFLTGIadvu-m4yqaRBoVT3uSRn7sLqNnX-I2uXKHaqgJ9SxY_VjedzAio0?key=4vIdmt73mUh-cJZAdQrc2w)

**C. Pre-run Checklist**

Final checklist before running:

* Variables are filled correctly as per the environment.
* Admin user created, and credentials are working.
* The collection is imported and opened in Postman.
* No missing or invalid values.

**D. Run the Collection**

* Open Postman and locate the collection named "MDMS v2 inbox Creation".
* Click the three dots (⋮) next to the collection name (on the right side).
* On the right side of the new screen, you’ll see an orange button labelled "Run MDMS v2 inbox Creation" — click this.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXflgpCDnkpsAsLv1ZDe35mrkRPbiIzWhGgwH61OaGSCBw1ykdwXkTkKSkAgPwnhybtZE1l52F-5YCTiy78xEx5Mf-MX54Wov-B-lWTHvm6B8S8LjfrcuCdSSUwZjymMXbl-eoyn?key=4vIdmt73mUh-cJZAdQrc2w)

* The collection will now start running. You will see each API request and its response as they execute.

**E. Check Results**

* ✅ If all requests succeed (green checkmarks), your MDMS setup for Inbox V2 is complete.
* ❌ If any request fails (red cross), re-run the collection to retry the failed steps.

{% hint style="info" %}
**Important Note:** Master data should only be created after the initial schema creation API call has been successfully executed
{% endhint %}
{% endstep %}

{% step %}

### Reindexing (Optional - Only if Needed)

Re-process older complaint data if it's missing from ElasticSearch due to errors or changes. If complaints are not appearing in the Inbox or ElasticSearch (due to Kafka failure, config change, or migration), reindexing helps restore that data.&#x20;

Make sure the following prerequisites are met before you begin with reindexing:

* Access to `kubectl`
* Access to `playground` pod
* Existing legacy indexer config available

### Steps for reindexing

1. **Import Reindexing Postman Collection**:
   1. Contains:
      * `pgr-services-legacy`
      * `pgr-services-legacy-kafkaconnector`
   2. **Run from Playground Pod**
2. **Create Kafka Connector**:

```http
POST http://kafka-connect.kafka-cluster:8083/connectors
```

3. **Trigger Legacy Indexing**\
   Push historical data  `/pgr-plainsearch` into Kafka.
4. **Monitor Logs**\
   Check the indexer pod logs to ensure reindexing is processing.
5. **Delete Kafka Connector**

```bash
bashCopyEditcurl --location --request DELETE \
'http://kafka-connect.kafka-cluster:8083/connectors/pgr-services-enriched-es-sink'
```

**Copy the enriched index back to the main index:**

```json
jsonCopyEditPOST _reindex
{
  "source": {
    "index": "pgr-services-enriched"
  },
  "dest": {
    "index": "pgr-services"
  }
}
```

{% endstep %}
{% endstepper %}

***

### Summary

<table><thead><tr><th width="85.38436889648438">Step</th><th width="208.9405517578125">What you do</th><th>Purpose</th></tr></thead><tbody><tr><td>1️⃣</td><td>Add Indexer config</td><td>Send PGR complaint data to ElasticSearch</td></tr><tr><td>2️⃣</td><td>Add Inbox MDMS config</td><td>Enable Inbox V2 to search and sort complaints</td></tr><tr><td>3️⃣</td><td>(Optional) Reindex</td><td>Fix data mismatch or reprocess missed entries</td></tr></tbody></table>

{% hint style="info" %}

### Tips

* Always restart the indexer and MDMS after changes.
* Verify Elastic index (pgr-services) has updated data.
* You can test your inbox filter via Postman using the /inbox/v2/\_search API.
  {% endhint %}
