Send text annotations back to ElasticSearch
9.7K
This simple application implements an ingestion process to:
The ingestion parameters (source, sink, fields mapping, etc.) can be set in config.yml file (in config directory).
Firstly install the Python libraries specified in requirements.txt.
To run:
python main.py --config config/config.yml
The ingestion process properties are configured in config.yml.
Entries under source key specify the ElasticSearch source.
Entries under sink key specify the ElasticSearch sink.
This only applies when ElasticSearch cluster is using X-Pack / Open Distro and requires secure connections with using SSL certificates. Under the key source and/or sink can be optionally specified security entry that will contain necessary configuration -- these are:
ca-certs-path -- the path to CA certificates file (PEM),client-cert-path -- the path to client certificate file (PEM),client-key-path -- the path to client key (PEM).Entires under the key extra_params are optional, useful for test cases or deployments where we only use internal resources:
use_ssl -- use ssl connection
verify_certs -- verify SSL certificates
credentials
username and password can be used to provide connection credentialsuse-api-key if this is enabled the username and password fields will be used as api_id and api_keyendpoint-urluse-bulk-indexing ingest in bulk mode (1000 docs / bulk chunk),Entries under mapping key define the mapping of the document fields for the ingestion.
The sub-entry source defines the field names that contain:
text-field - the free text to be processed,docid-field - the unique identifier of the document,persis-fields - a list of fields to be send back to the sink alongside each annotation entry.The sub-entry batch defines the possible portion of documents to be processed according to the date. The used fields are:
date-field - the name of the field containing the date,date-format - the format of the date/time used by ElasticSearch to specify the time window by the user (below),python-date-format - the format of the date/time used by Python to specify the time window by the user (below),interval - the number of days to be used for incremental batch processing in processing time window,date-start and date-end - the time window to be processed,threads - the number of processing threads to speed up the ingestion.The sub-entry sink specifies additional options during sending the processed annotations:
split-index-by-field - the name of the field in the returned annotations the value of which will be used as a prefix for the index name (e.g., used to send annotations of different types to separate indices). If you don't want this functionality simply leave the field empty, otherwise , to split by annotation type use typeThe sub-entry nlp specifies additional options during processing the documents with NLP:
skip-processed-doc-check - whether to skip checking for already processed documents in ElasticSearch,annotation-id-field - the name of field containing the annotation id returned from the NLP app.docker pull cogstacksystems/annotations-ingester:latest