Class PutMappingRequest

All Implemented Interfaces:
IndicesRequest, IndicesRequest.Replaceable, AckedRequest, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, org.elasticsearch.core.RefCounted, TaskAwareRequest

public class PutMappingRequest extends AcknowledgedRequest<PutMappingRequest> implements IndicesRequest.Replaceable, org.elasticsearch.common.xcontent.ToXContentObject
Puts mapping definition registered under a specific type into one or more indices. Best created with Requests.putMappingRequest(String...).

If the mappings already exists, the new mappings will be merged with the new one. If there are elements that can't be merged are detected, the request will be rejected.

See Also:
Requests.putMappingRequest(String...), IndicesAdminClient.putMapping(PutMappingRequest), AcknowledgedResponse
  • Constructor Details

    • PutMappingRequest

      public PutMappingRequest(StreamInput in) throws IOException
      Throws:
      IOException
    • PutMappingRequest

      public PutMappingRequest()
    • PutMappingRequest

      public PutMappingRequest(String... indices)
      Constructs a new put mapping request against one or more indices. If nothing is set then it will be executed against all indices.
  • Method Details

    • validate

      Specified by:
      validate in class ActionRequest
    • indices

      public PutMappingRequest indices(String... indices)
      Sets the indices this put mapping operation will execute on.
      Specified by:
      indices in interface IndicesRequest.Replaceable
    • setConcreteIndex

      public PutMappingRequest setConcreteIndex(Index index)
      Sets a concrete index for this put mapping request.
    • getConcreteIndex

      public Index getConcreteIndex()
      Returns a concrete index for this mapping or null if no concrete index is defined
    • indices

      public String[] indices()
      The indices the mappings will be put.
      Specified by:
      indices in interface IndicesRequest
    • indicesOptions

      public IndicesOptions indicesOptions()
      Description copied from interface: IndicesRequest
      Returns the indices options used to resolve indices. They tell for instance whether a single index is accepted, whether an empty array will be converted to _all, and how wildcards will be expanded if needed.
      Specified by:
      indicesOptions in interface IndicesRequest
    • indicesOptions

      public PutMappingRequest indicesOptions(IndicesOptions indicesOptions)
    • includeDataStreams

      public boolean includeDataStreams()
      Description copied from interface: IndicesRequest
      Determines whether the request should be applied to data streams. When false, none of the names or wildcard expressions in IndicesRequest.indices() should be applied to or expanded to any data streams. All layers involved in the request's fulfillment including security, name resolution, etc., should respect this flag.
      Specified by:
      includeDataStreams in interface IndicesRequest
    • type

      public String type()
      The mapping type.
    • type

      public PutMappingRequest type(String type)
      The type of the mappings.
    • source

      public String source()
      The mapping source definition.
    • source

      public PutMappingRequest source(Object... source)
      A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true"). Also supports metadata mapping fields such as `_all` and `_parent` as property definition, these metadata mapping fields will automatically be put on the top level mapping object.
    • origin

      public String origin()
    • origin

      public PutMappingRequest origin(String origin)
    • buildFromSimplifiedDef

      public static org.elasticsearch.common.xcontent.XContentBuilder buildFromSimplifiedDef(String type, Object... source)
      Parameters:
      type - the mapping type
      source - consisting of field/properties pairs (e.g. "field1", "type=string,store=true")
      Returns:
      the mappings definition
      Throws:
      IllegalArgumentException - if the number of the source arguments is not divisible by two
    • source

      public PutMappingRequest source(org.elasticsearch.common.xcontent.XContentBuilder mappingBuilder)
      The mapping source definition.
    • source

      public PutMappingRequest source(Map<String,?> mappingSource)
      The mapping source definition.
    • source

      public PutMappingRequest source(String mappingSource, org.elasticsearch.common.xcontent.XContentType xContentType)
      The mapping source definition.
    • source

      public PutMappingRequest source(BytesReference mappingSource, org.elasticsearch.common.xcontent.XContentType xContentType)
      The mapping source definition.
    • writeIndexOnly

      public PutMappingRequest writeIndexOnly(boolean writeIndexOnly)
    • writeIndexOnly

      public boolean writeIndexOnly()
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class AcknowledgedRequest<PutMappingRequest>
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      IOException