Class IngestPipelineTestUtils

java.lang.Object
org.elasticsearch.ingest.IngestPipelineTestUtils

public class IngestPipelineTestUtils extends Object
Utils for creating/retrieving/deleting ingest pipelines in a test cluster.
  • Method Details

    • putJsonPipelineRequest

      public static PutPipelineRequest putJsonPipelineRequest(String id, BytesReference source)
      Parameters:
      id - The pipeline id.
      source - The body of the PutPipelineRequest as a JSON-formatted BytesReference.
      Returns:
      a new PutPipelineRequest with the given id and body.
    • putJsonPipelineRequest

      public static PutPipelineRequest putJsonPipelineRequest(String id, String jsonString)
      Parameters:
      id - The pipeline id.
      jsonString - The body of the PutPipelineRequest as a JSON-formatted String.
      Returns:
      a new PutPipelineRequest with the given id and body.
    • putJsonPipeline

      public static void putJsonPipeline(ElasticsearchClient client, String id, BytesReference source)
      Create an ingest pipeline with the given ID and body, using the given ElasticsearchClient.
      Parameters:
      client - The client to use to execute the PutPipelineTransportAction.
      id - The pipeline id.
      source - The body of the PutPipelineRequest as a JSON-formatted BytesReference.
    • putJsonPipeline

      public static void putJsonPipeline(ElasticsearchClient client, String id, String jsonString)
      Create an ingest pipeline with the given ID and body, using the given ElasticsearchClient.
      Parameters:
      client - The client to use to execute the PutPipelineTransportAction.
      id - The pipeline id.
      jsonString - The body of the PutPipelineRequest as a JSON-formatted String.
    • putJsonPipeline

      public static void putJsonPipeline(ElasticsearchClient client, String id, org.elasticsearch.xcontent.ToXContentFragment toXContent) throws IOException
      Create an ingest pipeline with the given ID and body, using the given ElasticsearchClient.
      Parameters:
      client - The client to use to execute the PutPipelineTransportAction.
      id - The pipeline id.
      toXContent - The body of the PutPipelineRequest as a ToXContentFragment.
      Throws:
      IOException
    • deletePipelinesIgnoringExceptions

      public static void deletePipelinesIgnoringExceptions(ElasticsearchClient client, Iterable<String> ids)
      Attempt to delete the ingest pipeline with the given id, using the given ElasticsearchClient, and logging (but otherwise ignoring) the result.
    • jsonSimulatePipelineRequest

      public static SimulatePipelineRequest jsonSimulatePipelineRequest(String jsonString)
      Construct a new SimulatePipelineRequest whose content is the given JSON document, represented as a String.
    • jsonSimulatePipelineRequest

      public static SimulatePipelineRequest jsonSimulatePipelineRequest(BytesReference jsonBytes)
      Construct a new SimulatePipelineRequest whose content is the given JSON document, represented as a BytesReference.
    • doWithRandomAccessPattern

      public static void doWithRandomAccessPattern(IngestDocument document, Consumer<IngestDocument> action) throws Exception
      Executes an action against an ingest document using a random access pattern. A synthetic pipeline instance with the provided access pattern is created and executed against the ingest document, thus updating its internal access pattern.
      Parameters:
      document - The document to operate on
      action - A consumer which takes the updated ingest document during execution
      Throws:
      Exception - Any exception thrown from the provided consumer
    • doWithAccessPattern

      public static void doWithAccessPattern(IngestPipelineFieldAccessPattern accessPattern, IngestDocument document, Consumer<IngestDocument> action) throws Exception
      Executes an action against an ingest document using a random access pattern. A synthetic pipeline instance with the provided access pattern is created and executed against the ingest document, thus updating its internal access pattern.
      Parameters:
      accessPattern - The access pattern to use when executing the block of code
      document - The document to operate on
      action - A consumer which takes the updated ingest document during execution
      Throws:
      Exception - Any exception thrown from the provided consumer
    • runWithRandomAccessPattern

      public static IngestDocument runWithRandomAccessPattern(IngestDocument document, Processor processor) throws Exception
      Executes a processor against an ingest document using a random access pattern. A synthetic pipeline instance with the provided access pattern is created and executed against the ingest document, thus updating its internal access pattern.
      Parameters:
      document - The document to operate on
      processor - A processor which takes the updated ingest document during execution
      Returns:
      the resulting ingest document instance
      Throws:
      Exception - Any exception thrown from the provided consumer
    • runWithAccessPattern

      public static IngestDocument runWithAccessPattern(IngestPipelineFieldAccessPattern accessPattern, IngestDocument document, Processor processor) throws Exception
      Executes a processor against an ingest document using the provided access pattern. A synthetic pipeline instance with the provided access pattern is created and executed against the ingest document, thus updating its internal access pattern.
      Parameters:
      accessPattern - The access pattern to use when executing the block of code
      document - The document to operate on
      processor - A processor which takes the updated ingest document during execution
      Returns:
      the resulting ingest document instance
      Throws:
      Exception - Any exception thrown from the provided consumer