Indexing Service

Build Status Dependencies Coverage Status

A microservice for indexing events.

Features

  • Consumes resources via Kafka topics, transforms the event messages and inserts the result into Elasticsearch.

Indices

The service creates a mapping on ElasticSearch for each index found via the elasticsearch.indices config value with a valid loadable mapping under the mappings/ directory if the mapping is not already created. By default, it appends the fields created and modified as date fields in each resource mapping, since they are always set in every document in Restore Commerce services using the resource-base-interface.

Special Field Types

The service supports custom handling for some special field types:

  • geo_points fields get converted from ` { "longitude": 0, "latitude": 0 } ` to ` { "lon": 0, "lat": 0 } `

  • completion fields get set to

"<targetField>-suggest": {
  "input": words(targetFieldValue),
  "output": targetFieldValue,
  "payload": {
    "id": "this.id"
  }
}

Events

  • The service consumes messages dispatched from CRUD operations from all topics within the format <prefix>.<resourceName>s.resource (e.g: io.restorecommerce.users.resource).

  • It also subscribes to system commands and emits command responses on topic io.restorecommerce.command.

Command Interface

Restore

The command-interface’s restore method is overridden in this service in order to restore data related to one or more indices on ElasticSearch by reprocessing Kafka messages from a given starting offset. In order to prevent any overlap with a restore method of another service, the entities on the restore command’s payload should be in the format ${entity}_index. For example, address_index specifies the address index.

Reset

The reset command deletes all documents from all managed indices.

Usage

See tests.