search-ingest v2.0.1
PostgreSQL Elasticsearch Ingest Service
A small (one might even say 'micro') service that hooks into pg-orm models and generates elasticsearch indices. search-ingest exposes a REST API to reindex/backfill specific models.
Usage
- Set the tables to be mirrored in ES through setting
SearchIngest::MANAGED_TABLESwith an array of(T < PgORM::Base).class - Configure Elastic client through
ELASTIC_HOSTandELASTIC_PORTenv vars, or through switches on the command line - Configure PostgreSQL connection
PG_DATABASE_URLenv var
POST /api/v1/reindex[?backfill=true]
Deletes indexes and recreates index mappings. Backfills the indices by default (toggle with backfill boolean).
POST /api/v1/backfill
Backfills all indexes with data from PostgreSQL.
GET /api/v1/healthz
Healthcheck.
Index Schema
- Each PostgreSQL table receives an ES index, with a mapping generated from the attributes of a PgORM model.
- PgORM attributes can accept a tag
es_typeto specify the correct field datatype for the index schema. belongs_toassociations are modeled with ESjoindatatypes, associated documents are replicated in their parent's index. This is necessary forhas_parentandhas_childqueries.
PostgreSQL Mirroring
SearchIngest::TableManager hooks into the changefeed of a table, resolves associations of the model and creates/updates documents in the appropriate ES indices.
Configuration
ENV: A value ofproductionlowers log verbosityES_HOST: Elasticsearch hostES_PORT: Elasticsearch portES_TLS: Use Elasticsearch https, default isfalseES_URI: Elasticsearch uri, detects whether to use TLS off schemaES_DISABLE_BULK: Use single requests to Elasticsearch instead of the bulk API. Defaults tofalseES_CONN_POOL_TIMEOUT: Timeout when checking a connection out of the Elasticsearch connection poolES_CONN_POOL: Size of the Elasticsearch connection poolES_IDLE_POOL: Maximum number of idle connections in the Elasticsearch connection poolUDP_LOG_HOST: Host for sending JSON formatted logs toUDP_LOG_PORT: Port that UDP input service is listening onPG_DATABASE: DB to mirror to Elasticsearch, defaults to"test"PG_HOST: Host of PostgreSQL, defaults tolocalhostPG_PORT: Port of PostgreSQL, defaults to5432PG_USER: PostgreSQL database user, defaults topostgresPG_PWD: PostgreSQL database password, defaults to""PLACE_SEARCH_INGEST_HOST: Host to bind server toPLACE_SEARCH_INGEST_PORT: Port for server to listen on
Contributing
See CONTRIBUTING.md.
Contributors
- Caspian Baska - creator and maintainer
Repository
search-ingest
Owner
Statistic
- 2
- 2
- 0
- 2
- 11
- about 10 hours ago
- March 7, 2019
License
MIT License
Links
Synced at
Thu, 30 Oct 2025 04:44:09 GMT
Languages