本文整理汇总了Java中org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java GetMappingsRequestBuilder类的具体用法?Java GetMappingsRequestBuilder怎么用?Java GetMappingsRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetMappingsRequestBuilder类属于org.elasticsearch.action.admin.indices.mapping.get包,在下文中一共展示了GetMappingsRequestBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的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;
}
示例2: insertSchema
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的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));
}
示例3:
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的package包/类
/**
* Gets the mappings response.
*
* @param indices
* the indices
* @return the mappings response
*/
public ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>>
getMappingsResponse(String... indices) {
GetMappingsRequestBuilder getMappingsRequestBuilder =
admin().indices().prepareGetMappings(indices);
return JMElastricsearchUtil.logExcuteAndReturn("getMappingsResponse",
getMappingsRequestBuilder, getMappingsRequestBuilder.execute())
.getMappings();
}
示例4: getDynamicFieldNames
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的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;
}
示例5: prepareGetMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的package包/类
@Override
public GetMappingsRequestBuilder prepareGetMappings(String... indices) {
return new GetMappingsRequestBuilder(this, GetMappingsAction.INSTANCE, indices);
}
示例6: getMapping
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的package包/类
private static GetMappingsRequestBuilder getMapping(String... indices) {
return client().admin().indices().prepareGetMappings(indices);
}
示例7: prepareGetMappings
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequestBuilder; //导入依赖的package包/类
/**
* Get the complete mappings of one or more types
*/
GetMappingsRequestBuilder prepareGetMappings(String... indices);