*/
@SuppressWarnings({"unchecked"})
public class Mapping {
public static PutMappingRequest getPutMappingRequest(final Client client, final String index, final String analyzer) {
final PutMappingRequestBuilder builder = client.admin().indices().preparePutMapping(new String[] {index});
builder.setType(Messages.TYPE);
final Map<String, Object> mapping = new HashMap<String, Object>();
mapping.put("properties", partFieldProperties(analyzer));
mapping.put("dynamic_templates", partDefaultAllInDynamicTemplate());
mapping.put("_source", enabledAndCompressed()); // Compress source field..
mapping.put("_ttl", enabled()); // Enable purging by TTL.
// TODO: use multimap?
final Map<String, Map<String, Object>> completeMapping = Maps.newHashMap();
completeMapping.put(Messages.TYPE, mapping);
builder.setSource(completeMapping);
return builder.request();
}