use of org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse in project elasticsearch-opennlp-plugin by spinscale.
the class OpenNlpPluginIntegrationTest method putMapping.
private void putMapping(String mappingFile) throws IOException {
String mapping = copyToStringFromClasspath(mappingFile);
PutMappingRequestBuilder putMappingRequestBuilder = new PutMappingRequestBuilder(node.client().admin().indices());
PutMappingResponse putMappingResponse = putMappingRequestBuilder.setIndices(index).setType(type).setSource(mapping).execute().actionGet();
assertThat(putMappingResponse.isAcknowledged(), is(true));
}
use of org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse in project titan by thinkaurelius.
the class ElasticSearchIndex method register.
@Override
public void register(String store, String key, KeyInformation information, TransactionHandle tx) throws StorageException {
XContentBuilder mapping = null;
Class<?> dataType = information.getDataType();
Mapping map = Mapping.getMapping(information);
Preconditions.checkArgument(map == Mapping.DEFAULT || AttributeUtil.isString(dataType), "Specified illegal mapping [%s] for data type [%s]", map, dataType);
try {
mapping = XContentFactory.jsonBuilder().startObject().startObject(store).startObject("properties").startObject(key);
if (AttributeUtil.isString(dataType)) {
log.debug("Registering string type for {}", key);
mapping.field("type", "string");
if (map == Mapping.STRING)
mapping.field("index", "not_analyzed");
} else if (dataType == Float.class || dataType == FullFloat.class) {
log.debug("Registering float type for {}", key);
mapping.field("type", "float");
} else if (dataType == Double.class || dataType == FullDouble.class) {
log.debug("Registering double type for {}", key);
mapping.field("type", "double");
} else if (dataType == Byte.class) {
log.debug("Registering byte type for {}", key);
mapping.field("type", "byte");
} else if (dataType == Short.class) {
log.debug("Registering short type for {}", key);
mapping.field("type", "short");
} else if (dataType == Integer.class) {
log.debug("Registering integer type for {}", key);
mapping.field("type", "integer");
} else if (dataType == Long.class) {
log.debug("Registering long type for {}", key);
mapping.field("type", "long");
} else if (dataType == Boolean.class) {
log.debug("Registering boolean type for {}", key);
mapping.field("type", "boolean");
} else if (dataType == Geoshape.class) {
log.debug("Registering geo_point type for {}", key);
mapping.field("type", "geo_point");
}
mapping.endObject().endObject().endObject().endObject();
} catch (IOException e) {
throw new PermanentStorageException("Could not render json for put mapping request", e);
}
try {
PutMappingResponse response = client.admin().indices().preparePutMapping(indexName).setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet();
} catch (Exception e) {
throw convert(e);
}
}
Aggregations