java.lang.Object
org.elasticsearch.action.index.IndexSource
- All Implemented Interfaces:
Closeable,AutoCloseable,Writeable,Releasable
The
IndexSource is a class which holds the source for an IndexRequest. This class is designed to encapsulate the source
lifecycle and allow the bytes to be accessed and released when reserialized.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbytes()voidclose()static XContentBuildergetXContentBuilder(XContentType xContentType, Object... source) Returns an XContentBuilder for the given xContentType and source arraybooleanbooleanisClosed()voidsource(byte[] source, int offset, int length, XContentType contentType) Sets the document to index in bytes form (assumed to be safe to be used from different threads).voidsource(byte[] source, XContentType contentType) Sets the document to index in bytes form.voidSets the content source to index using the default content type (Requests.INDEX_CONTENT_TYPE)voidsource(String source, XContentType xContentType) Sets the document source to index.voidIndex the Map inRequests.INDEX_CONTENT_TYPEformatvoidsource(Map<String, ?> source, XContentType contentType) Index the Map as the provided content type.voidsource(Map<String, ?> source, XContentType contentType, boolean ensureNoSelfReferences) voidsource(BytesReference source, XContentType contentType) Sets the document to index in bytes form.voidsource(ReleasableBytesReference source, XContentType contentType) voidsource(XContentBuilder sourceBuilder) Sets the content source to index.voidsource(XContentType xContentType, Object... source) Sets the content source to index.voidwriteTo(StreamOutput out) Write this into the StreamOutput.
-
Constructor Details
-
IndexSource
public IndexSource() -
IndexSource
-
IndexSource
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
contentType
-
bytes
-
hasSource
public boolean hasSource() -
byteLength
public int byteLength() -
isClosed
public boolean isClosed() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-
sourceAsMap
-
source
Index the Map inRequests.INDEX_CONTENT_TYPEformat- Parameters:
source- The map to index- Throws:
ElasticsearchGenerationException
-
source
public void source(Map<String, ?> source, XContentType contentType) throws ElasticsearchGenerationExceptionIndex the Map as the provided content type.- Parameters:
source- The map to index- Throws:
ElasticsearchGenerationException
-
source
public void source(Map<String, ?> source, XContentType contentType, boolean ensureNoSelfReferences) throws ElasticsearchGenerationException- Throws:
ElasticsearchGenerationException
-
source
Sets the document source to index.Note, its preferable to either set it using
source(org.elasticsearch.xcontent.XContentBuilder)or using thesource(byte[], XContentType). -
source
Sets the content source to index. -
source
Sets the content source to index using the default content type (Requests.INDEX_CONTENT_TYPE)Note: the number of objects passed to this method must be an even number. Also the first argument in each pair (the field name) must have a valid String representation.
-
source
Sets the content source to index.Note: the number of objects passed to this method as varargs must be an even number. Also the first argument in each pair (the field name) must have a valid String representation.
-
getXContentBuilder
Returns an XContentBuilder for the given xContentType and source arrayNote: the number of objects passed to this method as varargs must be an even number. Also the first argument in each pair (the field name) must have a valid String representation.
-
source
-
source
Sets the document to index in bytes form. -
source
Sets the document to index in bytes form. -
source
Sets the document to index in bytes form (assumed to be safe to be used from different threads).- Parameters:
source- The source to indexoffset- The offset in the byte arraylength- The length of the data
-