public <IFD extends IndexFieldData<?>> IFD getForField(FieldDataType type, String fieldName) { final FieldMapper<?> mapper; final BuilderContext context = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1)); if (type.getType().equals("string")) { mapper = MapperBuilders.stringField(fieldName) .tokenized(false) .fieldDataSettings(type.getSettings()) .build(context); } else if (type.getType().equals("float")) { mapper = MapperBuilders.floatField(fieldName).fieldDataSettings(type.getSettings()).build(context); } else if (type.getType().equals("double")) { mapper = MapperBuilders.doubleField(fieldName) .fieldDataSettings(type.getSettings()) .build(context); } else if (type.getType().equals("long")) { mapper = MapperBuilders.longField(fieldName).fieldDataSettings(type.getSettings()).build(context); } else if (type.getType().equals("int")) { mapper = MapperBuilders.integerField(fieldName) .fieldDataSettings(type.getSettings()) .build(context); } else if (type.getType().equals("short")) { mapper = MapperBuilders.shortField(fieldName).fieldDataSettings(type.getSettings()).build(context); } else if (type.getType().equals("byte")) { mapper = MapperBuilders.byteField(fieldName).fieldDataSettings(type.getSettings()).build(context); } else if (type.getType().equals("geo_point")) { mapper = MapperBuilders.geoPointField(fieldName) .fieldDataSettings(type.getSettings()) .build(context); } else if (type.getType().equals("_parent")) { mapper = MapperBuilders.parent().type(fieldName).build(context); } else if (type.getType().equals("binary")) { mapper = MapperBuilders.binaryField(fieldName) .fieldDataSettings(type.getSettings()) .build(context); } else { throw new UnsupportedOperationException(type.getType()); } return ifdService.getForField(mapper); }