Join processor

The join processor concatenates the elements of an array into a single string value, using a specified separator between each element. It throws an exception if the provided input is not an array.

The following is the syntax for the join processor:

  1. {
  2. "join": {
  3. "field": "field_name",
  4. "separator": "separator_string"
  5. }
  6. }

copy

Configuration parameters

The following table lists the required and optional parameters for the join processor.

ParameterRequired/OptionalDescription
fieldRequiredThe name of the field to which the join operator is applied. Must be an array.
separatorRequiredA string separator to use when joining field values. If not specified, then the values are concatenated without a separator.
target_fieldOptionalThe field to assign the cleaned value to. If not specified, then the field is updated in place.
descriptionOptionalA description of the processor’s purpose or configuration.
ifOptionalSpecifies to conditionally execute the processor.
ignore_failureOptionalSpecifies to ignore failures for the processor. See Handling pipeline failures.
on_failureOptionalSpecifies to handle failures for the processor. See Handling pipeline failures.
tagOptionalAn identifier for the processor. Useful for debugging and metrics.

Using the processor

Follow these steps to use the processor in a pipeline.

Step 1: Create a pipeline

The following query creates a pipeline named example-join-pipeline that uses the join processor to concatenate all the values of the uri field, separating them with the specified separator /:

  1. PUT _ingest/pipeline/example-join-pipeline
  2. {
  3. "description": "Example pipeline using the join processor",
  4. "processors": [
  5. {
  6. "join": {
  7. "field": "uri",
  8. "separator": "/"
  9. }
  10. }
  11. ]
  12. }

copy

Step 2 (Optional): Test the pipeline

It is recommended that you test your pipeline before you ingest documents.

To test the pipeline, run the following query:

  1. POST _ingest/pipeline/example-join-pipeline/_simulate
  2. {
  3. "docs": [
  4. {
  5. "_source": {
  6. "uri": [
  7. "app",
  8. "home",
  9. "overview"
  10. ]
  11. }
  12. }
  13. ]
  14. }

copy

Response

The following example response confirms that the pipeline is working as expected:

  1. {
  2. "docs": [
  3. {
  4. "doc": {
  5. "_index": "_index",
  6. "_id": "_id",
  7. "_source": {
  8. "uri": "app/home/overview"
  9. },
  10. "_ingest": {
  11. "timestamp": "2024-05-24T02:16:01.00659117Z"
  12. }
  13. }
  14. }
  15. ]
  16. }

copy

Step 3: Ingest a document

The following query ingests a document into an index named testindex1:

  1. POST testindex1/_doc/1?pipeline=example-join-pipeline
  2. {
  3. "uri": [
  4. "app",
  5. "home",
  6. "overview"
  7. ]
  8. }

copy

Step 4 (Optional): Retrieve the document

To retrieve the document, run the following query:

  1. GET testindex1/_doc/1

copy