Get Field Mappings API
editGet Field Mappings API
editGet Field Mappings Request
editA GetFieldMappingsRequest
can have an optional list of indices, optional list of types and the list of fields:
Optional arguments
editThe following arguments can also optionally be provided:
Setting |
Synchronous Execution
editGetFieldMappingsResponse response = client.indices().getFieldMapping(request, RequestOptions.DEFAULT);
Asynchronous Execution
editThe asynchronous execution of a get mappings request requires both the
GetFieldMappingsRequest
instance and an ActionListener
instance to be passed to
the asynchronous method:
The asynchronous method does not block and returns immediately. Once it is
completed the ActionListener
is called back using the onResponse
method if
the execution successfully completed or using the onFailure
method if it
failed.
A typical listener for GetMappingsResponse
looks like:
Get Field Mappings Response
editThe returned GetFieldMappingsResponse
allows to retrieve information about the
executed operation as follows:
final Map<String, Map<String, Map<String, GetFieldMappingsResponse.FieldMappingMetaData>>> mappings = response.mappings(); final Map<String, GetFieldMappingsResponse.FieldMappingMetaData> typeMappings = mappings.get("twitter").get("_doc"); final GetFieldMappingsResponse.FieldMappingMetaData metaData = typeMappings.get("message"); final String fullName = metaData.fullName(); final Map<String, Object> source = metaData.sourceAsMap();