Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Overview

Indexer service runs as a separate service, This service is designed to perform all the indexing tasks of the digit platform. The service reads records posted on specific kafka topics and picks the corresponding index configuration from the yaml file provided by the respective module.Objective of Indexer service are listed as below.

  • To provide a one stop framework for indexing the data to elasticsearch.

  • To create provision for indexing live data, reindexing from one index to the other and indexing legacy data from the datastore.

Pre-requisites

Before you proceed with the configuration, make sure the following pre-requisites are met -

  1. Prior Knowledge of Java/J2EE.

  2. Prior Knowledge of SpringBoot.

  3. Prior Knowledge of Elasticsearch.

  4. Prior Knowledge of REST APIs and related concepts like path parameters, headers, JSON etc.

  5. Prior Knowledge of Kafka and related concepts like Producer, Consumer, Topic etc.

Key Functionalities

  • Performs three major tasks namely: LiveIndex, Reindex and LegacyIndex.

  • LiveIndex: Task of indexing the live transaction data on the platform. This keeps the es data in sync with the db. 

  • Reindex: Task of indexing data from one index to the other. ES already provides this feature, indexer does the same but with data transformation.

  • LegacyIndex: Task of indexing legacy data from the tables to ES. 

  • Provides flexibility to index the entire object, a part of the object or an entirely different custom object all using one input json from modules.

  • Provides features for customizing index json by field mapping, field masking, data enrichment through external APIs and data denormalization using MDMS.

  • One stop shop for all the es index requirements with easy-to-write and easy-to-maintain configuration files.

  • Designed as a consumer to save API overhead. The consumer configs are written from scratch to have complete control over the consumer behaviour. 

Deployment Details

  • Step 1: Write configuration as per your requirement. Structure of the config file is explained later in the same doc.

  • Step 2: Check-in the config file to a remote location preferably github, currently we check the files into this folder https://github.com/egovernments/configs/tree/DEV/egov-indexer -for dev

  • Step 3: Provide the absolute path of the checked-in file to DevOps, to add it to the file-read path of egov-indexer. The file will be added to egov-indexer's environment manifest file for it to be read at start-up of the application.

  • Step 4: Run the egov-indexer app, Since it is a consumer, it starts listening to the configured topics and indexes the data.

Interaction Diagram:

Configuration Details

As mentioned above, indexer uses a config file per module to store all the configurations pertaining to that module. Indexer reads multiple such files at start-up to support indexing for all the configured modules. The file contains following keys:

a. serviceName: Name of the module to which this configuration belongs.

b. summary: Summary of the module.

c. version: version of the configuration.

d. mappings: List of definitions within the module. Every definition corresponds to one index requirement. Which means, every object received onto the kafka queue can be used to create multiple indexes, each of these indexes will need configuration, all such configurations belonging to one topic forms one entry in the mappings list. The keys listed henceforth together form one definition and multiple such definitions are part of this mappings key.

       i. topic: Topic on which the data is to be received to activate this particular configuration.

       ii. configKey: Key to identify to what type of job is this config for. values: INDEX, REINDEX, LEGACYINDEX. INDEX: LiveIndex, REINDEX: Reindex, LEGACYINDEX: LegacyIndex.

      iii. indexes: Key to configure multiple index configurations for the data received on the particular topic. Multiple indexes based on different requirement can be created using the same object. This list of such configurations is a part of this key. uses the following keys:

  1. name: Index name on the elasticsearch. (Index will be created if it doesn't exist with this name.)

  2. type: Document type within that index to which the index json has to go. (Elasticsearch uses the structure of index/type/docId to locate any file within index/type with id = docId)

  3. id: Takes comma separated JsonPaths. The JSONPath is applied on the record received on the queue, the values hence obtained are appended and used as id for the record.

  4. isBulk: Boolean key to identify whether the JSON received on the Queue is from a Bulk API. In simple words, whether the JSON contains a list at the top level.

  5. jsonPath: Key to be used in case of indexing a part of the input JSON and in case of indexing a custom json where the values for custom json are to be fetched from this part of the input.

  6. timeStampField: JSONPath of the field in the input which can be used to obtain the timestamp of the input.

  7. fieldsToBeMasked: A list of JSONPaths of the fields of the input to be masked in the index.

  8. customJsonMapping: Key to be used while building an entirely different object using the input JSON on the queue. Has the following keys:

i) indexMapping: A skeleton/mapping of the JSON that is to be indexed. Note that, this JSON must always contain a key called "Data" at the top-level and the custom mapping begins within this key. This is only a convention to smoothen dashboarding on Kibana when data from multiple indexes have to be fetched for a single dashboard.

ii) fieldMapping: Contains a list of configurations. Each configuration contains keys to identify the field of the input JSON that has to be mapped to the fields of the index json which is mentioned in the key 'indexMapping' in the config. Has the following keys:

  1. inJsonPath: JSONPath of the field from the input.

  2. outJsonPath: JSONPath of the field of the index json.

        iii) externalUriMapping: Contains a list of configurations. Each configuration contains keys to identify the field of the input JSON that are to be enriched using APIs from the external services. The confiugration for those APIs also is a part of this. Uses the following keys:

 

  1. path: URI of the API to be used. (it should be POST/_search API.)

  2. queryParam: Configuration of the query params to be used for the API call. It is a comma seperated key-value pair, where key is the parameter name as per the API contract and value is the JSONPath of the field to be equated against this paramter.

  3. apiRequest: Request Body of the API. (Since we only use _search APIs, it should be only RequestInfo.)

  4. uriResponseMapping: Contains a list of configuration. Each configuration contains two keys: One is a JSONPath to identify the field from response, Second is also a JSONPath to map the response field to a field of the index json mentioned in the key 'indexMapping'.

i) inJsonPath: JSONPath to identify the field from response

ii) outJsonPath: JSONPath to map the response field to a field of the index json

iv) mdmsMapping: Contains a list of configurations. Each configuration contains keys to identify the field of the input JSON that are to be denormalized using APIs from the mdms service. The confiugration for those mdms APIs also is a part of this. Uses the following keys:

  1. path: URI of the API to be used. (it should be POST/_search    API.)

  2. moduleName: Module Name from MDMS.

  3. masterName: Master Name from MDMS.

  4. tenantId: Tenant id to be used.

  5. filter: filter to be applied on the data to be fetched.

  6. filterMapping: Maps the field of input json to variables in the filter

i) variable: Variable in the filter

      ii) valueJsonpath: JSONPath of the input to be mapped to the variable.

  1. uriResponseMapping: AS EXPLAINED ABOVE.

Reference - https://raw.githubusercontent.com/egovernments/punjab-rainmaker-customization/master/configs/egov-indexer/rainmaker-pgr-indexer.yml

API Details

a) POST /{key}/_index

Receive data and index. There should be a mapping with topic as {key} in index config files.

b) POST /_reindex

This is used to migrate data from one index to another index

c) POST /_legacyindex

This is to run LegacyIndex job to index data from DB. In the request body the URL of the service which would be called by indexer service to pick data, must be mentioned.

Note: In legacy indexing and for collection-service record LiveIndex kafka-connect is used to do part of pushing record to elastic search. For more details please refer to document mentioned in document list.

Reference Docs

Title 

Link

Using kafka-connect in egov-indexer reindexing jobs to push records to elastic search

https://digit-discuss.atlassian.net/l/c/Ktd5keeS

API Swagger Documentation

Swagger Documentation


  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.