Class SingleOperation
- java.lang.Object
-
- 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; thetype
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 usingBulkOperation
where appropriate.The action for each document is driven by the configured
ActionExtractor
instance. In the event of anDocumentAction.UPSERT
action then the sameXContentBuilder
from theDocumentWrapper
is used as both the update and upsert document viasource(XContentBuilder
} andsetUpsert(XContentBuilder)
. This makes the assumption that the document generated contains all the data required, not just a subset. If in doubt; stick to a normalDocumentAction.UPDATE
which will correctly throw aDocumentMissingException
.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 Summary
Fields Modifier and Type Field Description protected RequestBuilder
requestBuilder
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description SingleOperation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.adaptris.core.elastic.actions.ActionExtractor
actionExtractor()
protected AdaptrisMessage
doRequest(AdaptrisMessage msg, java.lang.String index, long timeout)
@NonNull @NotNull com.adaptris.core.elastic.actions.ActionExtractor
getAction()
The action for this operation if not explicitly defined by theDocumentWrapper
@NotNull @NonNull com.adaptris.core.elastic.ElasticDocumentBuilder
getDocumentBuilder()
How to build the document for elastic.java.lang.String
getRefreshPolicy()
The refresh policyvoid
setAction(@NonNull @NotNull com.adaptris.core.elastic.actions.ActionExtractor action)
The action for this operation if not explicitly defined by theDocumentWrapper
void
setDocumentBuilder(@NotNull @NonNull com.adaptris.core.elastic.ElasticDocumentBuilder documentBuilder)
How to build the document for elastic.void
setRefreshPolicy(java.lang.String refreshPolicy)
The refresh policy<T extends SingleOperation>
TwithAction(com.adaptris.core.elastic.actions.ActionExtractor b)
<T extends SingleOperation>
TwithDocumentBuilder(com.adaptris.core.elastic.ElasticDocumentBuilder b)
<T extends SingleOperation>
TwithRefreshPolicy(java.lang.String b)
-
Methods inherited from class com.adaptris.core.elastic.rest.ElasticRestProducer
defaultTimeout, doProduce, endpoint, getIndex, prepare, setIndex, withIndex
-
Methods inherited from class com.adaptris.core.RequestReplyProducerImp
produce, request, request
-
Methods inherited from class com.adaptris.core.RequestReplyProducerBase
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
-
Methods inherited from class com.adaptris.core.AdaptrisMessageProducerImp
createName
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
-
-
-
Field Detail
-
requestBuilder
protected transient RequestBuilder requestBuilder
-
-
Method Detail
-
doRequest
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String index, long timeout) throws ProduceException
- Specified by:
doRequest
in classRequestReplyProducerImp
- Throws:
ProduceException
-
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 theDocumentWrapper
If not explicitly defined then defaults to
ConfiguredAction
with a default ofINDEX
.
-
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 theDocumentWrapper
If not explicitly defined then defaults to
ConfiguredAction
with a default ofINDEX
.
-
getRefreshPolicy
public java.lang.String getRefreshPolicy()
The refresh policyThis would be generally "true", "false" or "wait_until". The default is null.
-
setRefreshPolicy
public void setRefreshPolicy(java.lang.String refreshPolicy)
The refresh policyThis would be generally "true", "false" or "wait_until". The default is null.
-
-