Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Uses Postgres JSONQuery instead of SQL Queries to fetch data from the Postgres DB.

    JSONQuery:
    JSONQuery is one of the exclusive features of Postgres, It provides a way of fetching data from the DB as JSON instead of ResultSet format. This saves the time spent is mapping ResultSet into required JSON formats at the functionality side.
    JSONQueries are similar to SQL queries with certain functions to internally map the ResultSet to JSON. SQL queries (SELECT queries to be precise) are passed as parameters to these functions, the SQL Query returns the ResultSet which is transformed to the JSON by these functions.
    Some of the functions extensively used are:
    1) row_to_json:  This function takes a query as a parameter and converts the result into JSON. However, the query must return only one row in the response. Note that, JSONQuery functions operate on aliases, So, the query must be mapped to an alias and the alias is passed to the function as a parameter.
    Eg: 
    {"name": "egov", "age": "20"}
    2) array_agg: This functions takes the output of row_to_json and aggregates it into an array of JSON. This is required when the query is returning multiple rows in the response. The query will be passed to row_to_json through an alias, this is further wrapped within array_agg to ensure all the rows returned by the query as converted to a JSONArray.
    Eg: 
    [{"name": "egov", "age": "20"},{"name": "egov", "age": "20"},{"name": "egov", "age": "20"}]
    3) array_to_json: This transforms the result of array_agg into a single JSON and returns it. This way, the response of a JSONQuery will always be a single JSON with the JSONArray of results attached to a key. This function is more for the final transformation of the result. The result so obtained can be easily cast to any other formats or operated on using the PGObject instance exposed by Postgres.
    Eg: 
    {"alias": [{"name": "egov", "age": "20"},{"name": "egov", "age": "20"},{"name": "egov", "age": "20"}]}

    For more details about JSONQuery, please check: https://www.postgresql.org/docs/9.4/functions-json.html

  2. Provides an easy way to set-up search APIs on the fly just by adding configurations without any coding effort.

  3. Provides flexibility to build where clause as per requirement, with config keys for operators, conditional blocks and other query clauses.

  4. Designed to use specific URI for every search request thereby making it easy for role-based access control.

  5. Fetches data in the form of JSON the format of which can be configured. This saves considerable effort in writing row mappers for every search result.

Interaction Diagram

...

Deployment Details

  1. Add configs for different modules required for Searcher Service.

  2. Deploy the latest version of Searcher Service.

  3. Add Role-Action mapping for API’s.

Integration

Integration Scope

The searcher service is used to search for data present in databases by running PSQL queries in the background.

Integration Benefits

  • Can perform service-specific business logic without impacting the other module.

  • In the future, if we want to expose the application to citizen then it can be done easily.

Steps to Integration

  1. To integrate, host of searcher-service module should be overwritten in helm chart.

  2. searcher/{moduleName}/{searchName}/_getshould be added as the search endpoint for the config added.

API Details

URI: The format of the search API to be used to fetch data using egov-searcher is as follows:  /egov-searcher/{moduleName}/{searchName}/_get

...