Skip to main content

ts-ids-es-json-generator

Introduction

This simple utility generates elasticsearch.json using schema.json.

How to Use

To run the generator, simply provide the program with the location of the IDS root directory:

$ pipenv run python -m ids_es_json_generator ~/path/to/ids/folder

elasticsearch.json may be manually edited after automatic generation (e.g. to update non-searchable fields).

Output

The script saves elasticsearch.json to the same directory you provided.

Assumptions

The generator operates under the following assumptions:

  • It's the IDS designer's responsibility to make sure the schema and elasticsearch.json are correct. The generator will not validate the IDS for you.

Restrictions

  • JSON pointers are dereferenced to create the mapping, so schemas with circular references or missing references will fail.

Tests

Run the tests using the following command:

$ pipenv run python -m pytest

How it works

Anywhere an array of objects appears in the schema, a nested field type will be created in the output elasticsearch.json, including arrays of objects contained anywhere within other arrays of objects. The steps are:

  1. The schema is loaded into a dict with all of its JSON pointers dereferenced using jsonref, so that nested fields involving definitions are included in the elasticsearch mapping.
  2. find_array_object will find all arrays of objects and create a dict representing their locations in the schema (see test case test_array_simple_nested_case in __tests__/unit/test_find_array_object.py).
  3. generate_es_mapping uses this dict to create the elasticsearch mapping (see test case test_nested_keys_case in __tests__/unit/test_generate_es_mapping.py).

See the example files and test cases for more example usage.

Metadata

Release files for ts-ids-es-json-generator 1.0.1

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

Source distribution (sdist)

Source distribution for ts-ids-es-json-generator 1.0.1
File Size Uploaded
ts-ids-es-json-generator-1.0.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ts-ids-es-json-generator 1.0.1
File Interpreter ABI Platform
ts_ids_es_json_generator-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / ts-ids-es-json-generator-1.0.1.tar.gz

Download URL ts-ids-es-json-generator-1.0.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c9ec2fe21a909700e5cd3feebe75f5a6b5045a282baee6e206226295c851fdcc
BLAKE2b-256 checksum
How to use checksums
d51cc0b68d36010671a96d922040634515e4acdc5da8cb939f1658dea7a1fc6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release files / ts_ids_es_json_generator-1.0.1-py3-none-any.whl

Download URL ts_ids_es_json_generator-1.0.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdd48ebfce1e8a24726db7c9b9385e5ce9fc46a334ccff959d030730c166661f
BLAKE2b-256 checksum
How to use checksums
45f942a872fd8ef1f93a47f3077658ff71dfd5d22a55d47a6fae523c1fac0e3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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