Skip to main content

openIMIS Backend opensearch_reports reference module

Adding Environmental Variables to Your Build

To configure environmental variables for your build, include the following:

  • OPENSEARCH_HOST - For the non-dockerized instance in a local context, set it to 0.0.0.0:9200. For the dockerized instance, use opensearch:9200.
  • OPENSEARCH_ADMIN This variable is used for the admin username. (default value: admin)
  • OPENSEARCH_PASSWORD This variable is used for the admin password. (default value: admin)

How to configure documents in openimis businesss module?

To configure Django ORM models with OpenSearch documents using a noSQL approach, follow these steps:

  • Begin by creating a documents.py file within your module.
  • Inside the documents.py file, define a Document class that corresponds to your Django ORM model. For example:
from django_opensearch_dsl.registries import registry
from django_opensearch_dsl import Document, fields as opensearch_fields

@registry.register_document
class BeneficiaryDocument(Document):
   benefit_plan = opensearch_fields.ObjectField(properties={
       'code': opensearch_fields.KeywordField(),
       'name': opensearch_fields.KeywordField(),
   })
   individual = opensearch_fields.ObjectField(properties={
       'first_name': opensearch_fields.KeywordField(),
       'last_name': opensearch_fields.KeywordField(),
       'dob': opensearch_fields.DateField(),
   })
   status = opensearch_fields.KeywordField(fields={
       'status_key': opensearch_fields.KeywordField()}
   )

   class Index:
       name = 'beneficiary'  # Name of the Opensearch index
       settings = {
           'number_of_shards': 1,
           'number_of_replicas': 0
       }
       auto_refresh = True # automatically send updates and new objects to openSearch

   class Django:
       model = Beneficiary
       related_models = [BenefitPlan, Individual]
       fields = [
           'id',
       ]
       queryset_pagination = 5000
  • In the Django class, you can use the fields property to include all the fields that are present in your Django ORM model.
  • If you wish to include related fields (foreign keys), make sure to specify them in the related_models property of your Django class. Add all the foreign key fields that you want to include.
    class Django:
        model = Beneficiary
        related_models = [BenefitPlan, Individual]
        fields = [
            'id',
        ]
        queryset_pagination = 5000
  • If you want to customize the default behavior of field creation, declare the fields you wish to modify using the appropriate type. For foreign keys, use the ObjectField type.
  @registry.register_document
  class BeneficiaryDocument(Document):
      benefit_plan = opensearch_fields.ObjectField(properties={
          'code': opensearch_fields.KeywordField(),
          'name': opensearch_fields.KeywordField(),
      })
      individual = opensearch_fields.ObjectField(properties={
          'first_name': opensearch_fields.KeywordField(),
          'last_name': opensearch_fields.KeywordField(),
          'dob': opensearch_fields.DateField(),
      })
      status = opensearch_fields.KeywordField(fields={
          'status_key': opensearch_fields.KeywordField()}
      )
  • Note that TextField types are typically converted to non-aggregable fields in OpenSearch. If you require aggregable fields, use the KeywordField type.
  • By default, the auto_refresh property in the Index class should enable data to be automatically transferred on every CRUD operation managed by Django ORM. Ensure that this property is properly configured in your project.

How to initialize data after deployment

  • If you have initialized the application but still have some data to be transferred, you can effortlessly achieve this by using the commands available in the business module: python manage.py add_<model_name>_data_to_opensearch. This command loads existing data into OpenSearch.

How to Import a Dashboard

  • Locate the dashboard definition file in .ndjson format within the openimis-be_<module-name>/import_data directory.
  • Log in to your OpenSearch instance.
  • Expand the sidebar located on the left side of the page.
  • Navigate to Management and select Dashboards Management.
  • On the left side of the page, click on Saved Objects.
  • At the top-right corner of the table, click on Import.
  • A new side-modal will appear on the right side of the page. Drag and drop the file from openimis-be_<module-name>/import_data into the import dropzone.
  • This action will import the dashboards along with related charts that should be accessible on the visualization page.
  • Verify if the dashboards have been imported properly.
  • Log in to your OpenSearch instance.
  • Expand the sidebar located on the left side of the page.
  • Navigate to Management and select Dashboards Management.
  • On the left side of the page, click on Saved Objects.
  • At the top-right corner of the table, click on Export <N> objects.
  • Ensure that you have selected dashboards only. Additionally, choose the option to include related objects, and then click export all.
  • You should have downloaded file in .ndjson format.
  • Save file in the business model for initialization after deployment in openimis-be_<module-name>/import_data.
  • Rename filename into opensearch_<model-name>_dashboard.ndjson

Developer tools

To upload opensearch configuration

  • from /openimis-be_py/openIMIS:
    • run this command: python manage.py upload_opensearch_dashboards --host-domain <host-domain> --imis-password <password>. This command will This command will upload dashboards config including charts, visualizations, indexes if the opensearch is available in package.
    • <password> - password necessary to log as admin user to obtain token to connect with API
    • <host-domain> is a hostname with http or https protocol for example https://release.openimis.org

Metadata

Release files for openimis-be-opensearch-reports 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openimis-be-opensearch-reports 1.5.0
File Size Uploaded Provenance Actions
openimis_be_opensearch_reports-1.5.0.tar.gz 29.2 kB Without provenance Details for openimis_be_opensearch_reports-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openimis-be-opensearch-reports 1.5.0
File Interpreter ABI Platform Actions
openimis_be_opensearch_reports-1.5.0-py3-none-any.whl Python 3 none any Details for openimis_be_opensearch_reports-1.5.0-py3-none-any.whl

Total release size: 66.7 kB

Release files / openimis_be_opensearch_reports-1.5.0.tar.gz

Download URL openimis_be_opensearch_reports-1.5.0.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b52d38efd5ad38e6707d283c073d515df38374f74c28d18dc6295fe80a4d8ebe
BLAKE2b-256 checksum
How to use checksums
d842738956b5b7e990508702d0ec67c0c3d14c1751ee14c2000d9fd667d1e915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

Release files / openimis_be_opensearch_reports-1.5.0-py3-none-any.whl

Download URL openimis_be_opensearch_reports-1.5.0-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf2a2abc55da57ee679e1f4b20045780e90d612f9c3071354dc73aaa8dd3ec19
BLAKE2b-256 checksum
How to use checksums
bd7c9a807937cb483ad98d78803404bab9b67dde0b398de3dba066f4071759cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

Security for openimis-be-opensearch-reports 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page