Class SingleOperation

  • All Implemented Interfaces:
    AdaptrisComponent, AdaptrisMessageProducer, AdaptrisMessageSender, AdaptrisMessageWorker, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator
    Direct Known Subclasses:
    BulkOperation

    @ComponentProfile(summary="Use the REST API to interact with an ElasticSearch instance",
                      tag="producer,elastic,elasticsearch",
                      since="3.9.1",
                      recommended=ElasticRestConnection.class)
    public class SingleOperation
    extends ElasticRestProducer
    INDEX/UPDATE/DELETE a document(s) to ElasticSearch.

    ElasticRestProducer.getIndex() should return the index of document that we are submitting to into ElasticSearch; the type will be derived from the DocumentWrapper itself.

    Of course, you can configure a ElasticDocumentBuilder implementation that creates multiple documents, but this will mean that all operations are made individually using the standard single document API rather than the BULK API. For performance reasons you should consider using BulkOperation where appropriate.

    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 source(XContentBuilder} and setUpsert(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 correctly throw a DocumentMissingException.

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

    • Field Detail

    • Constructor Detail

      • SingleOperation

        public SingleOperation()
    • Method Detail

      • withDocumentBuilder

        public <T extends SingleOperation> T withDocumentBuilder​(com.adaptris.core.elastic.ElasticDocumentBuilder b)
      • withAction

        public <T extends SingleOperation> T withAction​(com.adaptris.core.elastic.actions.ActionExtractor b)
      • actionExtractor

        protected com.adaptris.core.elastic.actions.ActionExtractor actionExtractor()
      • withRefreshPolicy

        public <T extends SingleOperation> T withRefreshPolicy​(java.lang.String b)
      • getDocumentBuilder

        @NotNull
        @NonNull
        public @NotNull @NonNull com.adaptris.core.elastic.ElasticDocumentBuilder getDocumentBuilder()
        How to build the document for elastic.

        If not explicitly defined then defaults to SimpleDocumentBuilder

      • setDocumentBuilder

        public void setDocumentBuilder​(@NotNull @NonNull
                                       @NotNull @NonNull com.adaptris.core.elastic.ElasticDocumentBuilder documentBuilder)
        How to build the document for elastic.

        If not explicitly defined then defaults to SimpleDocumentBuilder

      • getAction

        @NonNull
        @NotNull
        public @NonNull @NotNull com.adaptris.core.elastic.actions.ActionExtractor getAction()
        The action for this operation if not explicitly defined by the DocumentWrapper

        If not explicitly defined then defaults to ConfiguredAction with a default of INDEX.

      • setAction

        public void setAction​(@NonNull @NotNull
                              @NonNull @NotNull com.adaptris.core.elastic.actions.ActionExtractor action)
        The action for this operation if not explicitly defined by the DocumentWrapper

        If not explicitly defined then defaults to ConfiguredAction with a default of INDEX.

      • getRefreshPolicy

        public java.lang.String getRefreshPolicy()
        The refresh policy

        This would be generally "true", "false" or "wait_until". The default is null.

      • setRefreshPolicy

        public void setRefreshPolicy​(java.lang.String refreshPolicy)
        The refresh policy

        This would be generally "true", "false" or "wait_until". The default is null.