本文整理汇总了Java中org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction类的典型用法代码示例。如果您正苦于以下问题:Java GetMappingsAction类的具体用法?Java GetMappingsAction怎么用?Java GetMappingsAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetMappingsAction类属于org.elasticsearch.action.admin.indices.mapping.get包,在下文中一共展示了GetMappingsAction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIngestCreation
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Test
public void testIngestCreation() throws Exception {
Settings settingsForIndex = Settings.settingsBuilder()
.put("index.number_of_shards", 1)
.build();
Map<String,String> mappings = new HashMap<>();
mappings.put("typename","{\"properties\":{\"message\":{\"type\":\"string\"}}}");
final IngestTransportClient ingest = ClientBuilder.builder()
.put(getSettings())
.setMetric(new LongAdderIngestMetric())
.toIngestTransportClient();
try {
ingest.newIndex("test", settingsForIndex, mappings);
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices("test");
GetMappingsResponse getMappingsResponse =
ingest.client().execute(GetMappingsAction.INSTANCE, getMappingsRequest).actionGet();
MappingMetaData md = getMappingsResponse.getMappings().get("test").get("typename");
assertEquals("{properties={message={type=string}}}", md.getSourceAsMap().toString());
} finally {
ingest.shutdown();
}
}
示例2: testGetMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
public void testGetMappings() {
interceptTransportActions(GetMappingsAction.NAME);
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases());
internalCluster().coordOnlyNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();
clearInterceptedActions();
assertSameIndices(getMappingsRequest, GetMappingsAction.NAME);
}
示例3: getAllMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ImmutableOpenMap<String, MappingMetaData> getAllMappings(String index) {
Object mapping = cache.get(makeKey(index));
if (mapping == null) {
mapping = new GetMappingsRequestBuilder(getClient(), GetMappingsAction.INSTANCE, index)
.get().mappings().get(index);
cache.put(makeKey(index), mapping);
}
return (ImmutableOpenMap<String, MappingMetaData>) mapping;
}
示例4: insertSchema
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Test
public void insertSchema() throws Exception {
sink.prepare(mapping);
IndicesAdminClient indicesClient = sink.getClient().admin().indices();
GetMappingsRequestBuilder builder = new GetMappingsRequestBuilder(indicesClient, GetMappingsAction.INSTANCE, mapping.getIndex())
.addTypes(mapping.getType());
GetMappingsResponse response = indicesClient.getMappings(builder.request()).actionGet();
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = response.getMappings();
Map<String, Object> recordTypeMap = mappings.get(mapping.getIndex()).get(mapping.getType()).getSourceAsMap();
assertThat("dynamic value is correct", Boolean.valueOf(recordTypeMap.get("dynamic").toString()), is(mapping.isDynamicMappingEnabled()));
Thread.sleep(1000);
// https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
String allMappingsResponse = Request
.Get("http://localhost:9200/_mapping/_all?pretty").execute()
.returnContent().asString();
assertThat("record type is provided (checking id property type", allMappingsResponse, hasJsonPath(mapping.getIndex() + ".mappings." + mapping.getType() + ".properties.id.type", is("string")));
assertThat("metadata type is provided (checking mt_update-time property type)", allMappingsResponse, hasJsonPath(mapping.getIndex() + ".mappings.mt.properties.mt-update-time.type", is("date")));
// https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html
StatusLine recordsStatus = Request
.Head("http://localhost:9200/" + mapping.getIndex() + "/" + mapping.getType()).execute()
.returnResponse().getStatusLine();
assertThat("records type is available", recordsStatus.getStatusCode(), is(200));
StatusLine mtStatus = Request
.Head("http://localhost:9200/" + mapping.getIndex() + "/mt").execute()
.returnResponse().getStatusLine();
assertThat("metadata type is available", mtStatus.getStatusCode(), is(200));
}
示例5: getDynamicFieldNames
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public List<String> getDynamicFieldNames() throws SearchEngineException {
List<String> fieldNames = new LinkedList<>();
try {
GetMappingsRequest req =
new GetMappingsRequestBuilder(client, GetMappingsAction.INSTANCE, configuration.getIndexName())
.setTypes(configuration.getDocType())
.request();
GetMappingsResponse response = client.admin().indices().getMappings(req).actionGet();
MappingMetaData metaData = response.getMappings()
.get(configuration.getIndexName())
.get(configuration.getDocType());
Map<String, Object> sourceMap = metaData.getSourceAsMap();
Object annotationField = ((Map)sourceMap.get("properties")).get(configuration.getAnnotationField());
Map<String, Object> annotationProperties = (Map<String, Object>)((Map)annotationField).get("properties");
if (annotationProperties != null) {
for (String field : annotationProperties.keySet()) {
if (field.matches(DYNAMIC_LABEL_FIELD_REGEX)) {
fieldNames.add(field);
}
}
}
} catch (IOException e) {
LOGGER.error("Caught IOException retrieving field source: {}", e.getMessage());
throw new SearchEngineException(e);
}
return fieldNames;
}
示例6: getMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public void getMappings(GetMappingsRequest request, ActionListener<GetMappingsResponse> listener) {
execute(GetMappingsAction.INSTANCE, request, listener);
}
示例7: prepareGetMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public GetMappingsRequestBuilder prepareGetMappings(String... indices) {
return new GetMappingsRequestBuilder(this, GetMappingsAction.INSTANCE, indices);
}
示例8: getAction
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
public GetMappingsAction getAction() {
return GetMappingsAction.INSTANCE;
}