use of org.elasticsearch.common.collect.ImmutableOpenMap in project elasticsearch by elastic.
the class DynamicMappingIT method assertMappingsHaveField.
private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String type, String field) throws IOException {
ImmutableOpenMap<String, MappingMetaData> indexMappings = mappings.getMappings().get("index");
assertNotNull(indexMappings);
MappingMetaData typeMappings = indexMappings.get(type);
assertNotNull(typeMappings);
Map<String, Object> typeMappingsMap = typeMappings.getSourceAsMap();
Map<String, Object> properties = (Map<String, Object>) typeMappingsMap.get("properties");
assertTrue("Could not find [" + field + "] in " + typeMappingsMap.toString(), properties.containsKey(field));
}
use of org.elasticsearch.common.collect.ImmutableOpenMap in project sonarqube by SonarSource.
the class IndexCreatorTest method create_index.
@Test
public void create_index() throws Exception {
assertThat(mappings()).isEmpty();
IndexDefinitions registry = new IndexDefinitions(new IndexDefinition[] { new FakeIndexDefinition() }, new MapSettings());
registry.start();
IndexCreator creator = new IndexCreator(es.client(), registry);
creator.start();
// check that index is created with related mapping
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = mappings();
MappingMetaData mapping = mappings.get("fakes").get("fake");
assertThat(mapping.type()).isEqualTo("fake");
assertThat(mapping.getSourceAsMap()).isNotEmpty();
assertThat(countMappingFields(mapping)).isEqualTo(2);
assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
assertThat(setting("fakes", "index.sonar_hash")).isNotEmpty();
// of course do not delete indices on stop
creator.stop();
assertThat(mappings()).isNotEmpty();
}
use of org.elasticsearch.common.collect.ImmutableOpenMap in project elasticsearch-skywalker by jprante.
the class MetaDataToXContent method toXContent.
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("version", metadata.version());
builder.field("numberOfShards", metadata.numberOfShards());
builder.startArray("concreteIndices");
for (String index : metadata.concreteAllIndices()) {
builder.value(index);
}
builder.endArray();
ImmutableOpenMap<String, ImmutableOpenMap<String, AliasMetaData>> aliases = metadata.getAliases();
builder.startArray("aliases");
for (ObjectCursor<String> alias : aliases.keys()) {
builder.startObject(alias.value);
builder.startArray("aliasMetadata");
for (ObjectCursor<String> s : aliases.get(alias.value).keys()) {
builder.startObject();
AliasMetaData amd = aliases.get(alias.value).get(s.value);
builder.field("alias", amd.getAlias());
builder.field("filter", amd.getFilter().string());
builder.field("indexRouting", amd.getIndexRouting());
builder.field("searchRouting", amd.getSearchRouting());
builder.endObject();
}
builder.endArray();
builder.endObject();
}
builder.endArray();
builder.startArray("indexes");
ImmutableOpenMap<String, IndexMetaData> indices = metadata.getIndices();
for (ObjectCursor<String> s : indices.keys()) {
IndexMetaData imd = indices.get(s.value);
builder.startObject();
builder.field("index", imd.getIndex());
builder.field("state", imd.getState().name());
builder.field("numberOfReplicas", imd.getNumberOfReplicas());
builder.field("numberOfShards", imd.getNumberOfShards());
builder.field("totalNumberOfShards", imd.getTotalNumberOfShards());
builder.field("version", imd.getVersion());
builder.field("settings", imd.getSettings().getAsMap());
ImmutableOpenMap<String, MappingMetaData> m = imd.getMappings();
// skip mappings here
builder.endObject();
}
builder.endArray();
builder.startArray("templates");
ImmutableOpenMap<String, IndexTemplateMetaData> templates = metadata.getTemplates();
for (ObjectCursor<String> s : templates.keys()) {
IndexTemplateMetaData itmd = templates.get(s.value);
itmd.getName();
itmd.getOrder();
itmd.getTemplate();
itmd.getSettings();
itmd.getMappings();
}
builder.endArray();
builder.endObject();
return builder;
}
use of org.elasticsearch.common.collect.ImmutableOpenMap in project graylog2-server by Graylog2.
the class Indices method areReopened.
public Map<String, Boolean> areReopened(Collection<String> indices) {
final ClusterStateResponse clusterState = c.admin().cluster().prepareState().all().get();
final ImmutableOpenMap<String, IndexMetaData> indicesMetaData = clusterState.getState().getMetaData().getIndices();
return indices.stream().collect(Collectors.toMap(index -> index, index -> checkForReopened(indicesMetaData.get(index))));
}
use of org.elasticsearch.common.collect.ImmutableOpenMap in project crate by crate.
the class DefaultTemplateService method createCopyWithDefaultTemplateAdded.
private static ImmutableOpenMap<String, IndexTemplateMetaData> createCopyWithDefaultTemplateAdded(ImmutableOpenMap<String, IndexTemplateMetaData> currentTemplates) throws IOException {
IndexTemplateMetaData defaultTemplate = IndexTemplateMetaData.builder(TEMPLATE_NAME).order(0).putMapping(Constants.DEFAULT_MAPPING_TYPE, DEFAULT_MAPPING_SOURCE).template("*").build();
ImmutableOpenMap.Builder<String, IndexTemplateMetaData> builder = ImmutableOpenMap.builder(currentTemplates);
builder.put(TEMPLATE_NAME, defaultTemplate);
return builder.build();
}
Aggregations