Class IndexRequest

    • Constructor Detail

      • IndexRequest

        public IndexRequest​(StreamInput in)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • IndexRequest

        public IndexRequest()
      • IndexRequest

        @Deprecated
        public IndexRequest​(java.lang.String index,
                            java.lang.String type)
        Deprecated.
        Types are in the process of being removed. Use IndexRequest(String) instead.
        Constructs a new index request against the specific index and type. The source(byte[], XContentType) must be set.
      • IndexRequest

        @Deprecated
        public IndexRequest​(java.lang.String index,
                            java.lang.String type,
                            java.lang.String id)
        Deprecated.
        Types are in the process of being removed. Use IndexRequest(String) with id(String) instead.
        Constructs a new index request against the index, type, id and using the source.
        Parameters:
        index - The index to index into
        type - The type to index into
        id - The id of document
    • Method Detail

      • getContentType

        public XContentType getContentType()
        The content type. This will be used when generating a document from user provided objects like Maps and when parsing the source at index time
      • type

        @Deprecated
        public java.lang.String type()
        Deprecated.
        Types are in the process of being removed.
        The type of the indexed document.
        Specified by:
        type in interface DocWriteRequest<IndexRequest>
        Returns:
        the type
      • type

        @Deprecated
        public IndexRequest type​(java.lang.String type)
        Deprecated.
        Types are in the process of being removed.
        Sets the type of the indexed document.
        Specified by:
        type in interface DocWriteRequest<IndexRequest>
        Returns:
        the Request
      • defaultTypeIfNull

        @Deprecated
        public IndexRequest defaultTypeIfNull​(java.lang.String defaultType)
        Deprecated.
        Types are in the process of being removed.
        Set the default type supplied to a bulk request if this individual request's type is null or empty
        Specified by:
        defaultTypeIfNull in interface DocWriteRequest<IndexRequest>
        Returns:
        the Request
      • id

        public java.lang.String id()
        The id of the indexed document. If not set, will be automatically generated.
        Specified by:
        id in interface DocWriteRequest<IndexRequest>
        Returns:
        the id
      • id

        public IndexRequest id​(java.lang.String id)
        Sets the id of the indexed document. If not set, will be automatically generated.
      • routing

        public IndexRequest routing​(java.lang.String routing)
        Controls the shard routing of the request. Using this value to hash the shard and not the id.
        Specified by:
        routing in interface DocWriteRequest<IndexRequest>
        Returns:
        the Request
      • routing

        public java.lang.String routing()
        Controls the shard routing of the request. Using this value to hash the shard and not the id.
        Specified by:
        routing in interface DocWriteRequest<IndexRequest>
        Returns:
        the Routing
      • setPipeline

        public IndexRequest setPipeline​(java.lang.String pipeline)
        Sets the ingest pipeline to be executed before indexing the document
      • getPipeline

        public java.lang.String getPipeline()
        Returns the ingest pipeline to be executed before indexing the document
      • setFinalPipeline

        public IndexRequest setFinalPipeline​(java.lang.String finalPipeline)
        Sets the final ingest pipeline to be executed before indexing the document.
        Parameters:
        finalPipeline - the name of the final pipeline
        Returns:
        this index request
      • getFinalPipeline

        public java.lang.String getFinalPipeline()
        Returns the final ingest pipeline to be executed before indexing the document.
        Returns:
        the name of the final pipeline
      • isPipelineResolved

        public IndexRequest isPipelineResolved​(boolean isPipelineResolved)
        Sets if the pipeline for this request has been resolved by the coordinating node.
        Parameters:
        isPipelineResolved - true if the pipeline has been resolved
        Returns:
        the request
      • isPipelineResolved

        public boolean isPipelineResolved()
        Returns whether or not the pipeline for this request has been resolved by the coordinating node.
        Returns:
        true if the pipeline has been resolved
      • source

        public BytesReference source()
        The source of the document to index, recopied to a new array if it is unsafe.
      • sourceAsMap

        public java.util.Map<java.lang.String,​java.lang.Object> sourceAsMap()
      • source

        public IndexRequest source​(java.lang.Object... 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

        public IndexRequest source​(XContentType xContentType,
                                   java.lang.Object... 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.

      • source

        public IndexRequest source​(byte[] source,
                                   XContentType xContentType)
        Sets the document to index in bytes form.
      • source

        public IndexRequest source​(byte[] source,
                                   int offset,
                                   int length,
                                   XContentType xContentType)
        Sets the document to index in bytes form (assumed to be safe to be used from different threads).
        Parameters:
        source - The source to index
        offset - The offset in the byte array
        length - The length of the data
      • opType

        public IndexRequest opType​(java.lang.String opType)
        Sets a string representation of the opType(OpType). Can be either "index" or "create".
      • version

        public IndexRequest version​(long version)
        Description copied from interface: DocWriteRequest
        Sets the version, which will perform the operation only if a matching version exists and no changes happened on the doc since then.
        Specified by:
        version in interface DocWriteRequest<IndexRequest>
      • ifSeqNo

        public long ifSeqNo()
        If set, only perform this indexing request if the document was last modification was assigned this sequence number. If the document last modification was assigned a different sequence number a VersionConflictEngineException will be thrown.
        Specified by:
        ifSeqNo in interface DocWriteRequest<IndexRequest>
      • resolveRouting

        public void resolveRouting​(MetaData metaData)
      • checkAutoIdWithOpTypeCreateSupportedByVersion

        public void checkAutoIdWithOpTypeCreateSupportedByVersion​(Version version)
      • isRetry

        public boolean isRetry()
        Returns true if this request has been sent to a shard copy more than once.
      • getAutoGeneratedTimestamp

        public long getAutoGeneratedTimestamp()
        Returns the timestamp the auto generated ID was created or -1L if the document has no auto generated timestamp. This method will return a positive value iff the id was auto generated.