Indexer
Overview
In DIGIT, the Indexer Service is used to store data in Elastic by listening to messages from Kafka topics.
It needs a configuration file (in YAML) to understand:
Which Kafka topic to listen to
What data to extract from the Kafka message
Where and how to insert/update this data in the database
Steps
Add YAML Config in Config Repo
Go to your GitHub config repo.
Use the right branch based on your environment from where your indexer service is reading data. Example - dev, uat, prod, master.
Add a new file named like this for the reference given in the link. There are two indexer files.
egov-indexer/pgr-services.yml
Reference link for the pgr-service.yml indexer config
egov-indexer/pgr-inbox-indexer.yml
Reference link for the pgr-inbox-indexer.yml indexer config
Sample Indexer Configuration (For CCRS)
ServiceMaps:
serviceName: Public Grievance Redressal - rainmaker
version: 1.0.0
mappings:
- topic: save-pgr-request
configKey: INDEX
indexes:
- name: inbox-pgr-services
type: general
id: $.service.serviceRequestId
jsonPath: $
timeStampField: $.service.auditDetails.createdTime
customJsonMapping:
indexMapping: {"Data":{"service":{},"tenantId": "","auditDetails": {},"currentProcessInstance": {}}}
fieldMapping:
- inJsonPath: $.service
outJsonPath: $.Data.service
- inJsonPath: $.service.tenantId
outJsonPath: $.Data.tenantId
- inJsonPath: $.service.auditDetails
outJsonPath: $.Data.auditDetails
- inJsonPath: $.service.processInstance
outJsonPath: $.Data.currentProcessInstance
- topic: update-pgr-request
configKey: INDEX
indexes:
- name: inbox-pgr-services
type: general
id: $.service.serviceRequestId
jsonPath: $
timeStampField: $.service.auditDetails.createdTime
customJsonMapping:
indexMapping: {"Data":{"service":{},"tenantId": "","auditDetails": {},"currentProcessInstance": {}}}
fieldMapping:
- inJsonPath: $.service
outJsonPath: $.Data.service
- inJsonPath: $.service.tenantId
outJsonPath: $.Data.tenantId
- inJsonPath: $.service.auditDetails
outJsonPath: $.Data.auditDetails
- inJsonPath: $.service.processInstance
outJsonPath: $.Data.currentProcessInstance
- topic: pgr-services-inboxIndex
configKey: LEGACYINDEX
indexes:
- name: inbox-pgr-services-legacy
type: general
isBulk: true
id: $.service.serviceRequestId
jsonPath: $.ServiceWrappers.*
timeStampField: $.service.auditDetails.createdTime
customJsonMapping:
indexMapping: {"Data":{"service":{},"tenantId": "","auditDetails": {},"currentProcessInstance": {}}}
fieldMapping:
- inJsonPath: $.service
outJsonPath: $.Data.service
- inJsonPath: $.service.tenantId
outJsonPath: $.Data.tenantId
- inJsonPath: $.service.auditDetails
outJsonPath: $.Data.auditDetails
- inJsonPath: $.service.ProcessInstances[0]
outJsonPath: $.Data.currentProcessInstance
- topic: pgr-service-reindex
configKey: REINDEX
indexes:
- name: pgrreindex-v2
type: general
id: $.Data.service.serviceRequestId
isBulk: true
jsonPath: $.hits
timeStampField: $.Data.service.auditDetails.lastModifiedTime
Copy and paste both the indexer configs
Copy and paste both the indexer configs into the created file.
Restart the indexer service to read the updated indexer file.
This file tells the indexer how to save CCRS complaints in Elastic Search.
How to read the details:
moduleName
Logical name (here, PGR)
topic
Kafka topic (like save-pgr-request) that triggers DB action
basePath
Root path in JSON (e.g.,$.or $.service) from which data is picked
jsonPath
Specific path in the request JSON to map to an elastic reference mapping column
Validate the configuration
Once the service is restarted:
Submit a PGR complaint (via API or UI)
Check:
A message is published on Kafka (e.g., save-pgr-request)
The data is stored in the Elastic (check the table Elastic Indexer)
If nothing happens:
Check that the topic name matches in both the application and the indexer YAML
Look for logs in the indexer pod for errors
Reference
Summary
The indexer config ensures compliant data is saved automatically when it is created or updated.
It works behind the scenes, triggered by Kafka.
You configure it using a simple YAML file to define what to save and where.
Restart the service after adding or editing the config.
Last updated
Was this helpful?