Class BulkOperation

All Implemented Interfaces:
AdaptrisComponent, AdaptrisMessageProducer, AdaptrisMessageSender, AdaptrisMessageWorker, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator

@ComponentProfile(summary="Use the REST API to interact with Elasticsearch", tag="producer,elastic,bulk,batch", recommended=ElasticRestConnection.class) public class BulkOperation extends SingleOperation
Index/Delete/Update a document(s) to ElasticSearch.

ElasticRestProducer.getIndex() should return the index that the documents will be inserted against ElasticSearch; the type is taken from the DocumentBuilder

The action for each document is driven by the configured ActionExtractor instance. In the event of an DocumentAction.UPSERT action then the same XContentBuilder from the DocumentWrapper is used as both the update and upsert document via doc(XContentBuilder} and upsert(XContentBuilder). This makes the assumption that the document generated contains all the data required, not just a subset. If in doubt; stick to a normal DocumentAction.UPDATE which will throw a DocumentMissingException failing the messages.

In the adapter configuration file this class is aliased as elastic-rest-bulk-operation which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • BulkOperation

      public BulkOperation()
  • Method Details

    • doRequest

      protected AdaptrisMessage doRequest(AdaptrisMessage msg, String index, long timeout) throws ProduceException
      Overrides:
      doRequest in class SingleOperation
      Throws:
      ProduceException
    • withBatchWindow

      public BulkOperation withBatchWindow(Integer i)
    • getBatchWindow

      public Integer getBatchWindow()
      The batch window which is the number of operations that make a bulk request before its executed.

      If not specified explicitly then the default is 10000

    • setBatchWindow

      public void setBatchWindow(Integer batchWindow)
      The batch window which is the number of operations that make a bulk request before its executed.

      If not specified explicitly then the default is 10000