try harder to load the default mapping from the class load, and if we fail, just use the default value (which people really never change).
This commit is contained in:
parent
0a5a068269
commit
68c76e6738
|
@ -114,6 +114,9 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
|
||||||
} catch (FailedToResolveConfigException e) {
|
} catch (FailedToResolveConfigException e) {
|
||||||
// not there, default to the built in one
|
// not there, default to the built in one
|
||||||
defaultMappingUrl = indexSettings.getClassLoader().getResource("org/elasticsearch/index/mapper/default-mapping.json");
|
defaultMappingUrl = indexSettings.getClassLoader().getResource("org/elasticsearch/index/mapper/default-mapping.json");
|
||||||
|
if (defaultMappingUrl == null) {
|
||||||
|
defaultMappingUrl = MapperService.class.getClassLoader().getResource("org/elasticsearch/index/mapper/default-mapping.json");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -128,11 +131,19 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaultMappingUrl == null) {
|
||||||
|
logger.info("failed to find default-mapping.json in the classpath, using the default template");
|
||||||
|
defaultMappingSource = "{\n" +
|
||||||
|
" \"_default_\":{\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
defaultMappingSource = Streams.copyToString(new InputStreamReader(defaultMappingUrl.openStream(), Charsets.UTF_8));
|
defaultMappingSource = Streams.copyToString(new InputStreamReader(defaultMappingUrl.openStream(), Charsets.UTF_8));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MapperException("Failed to load default mapping source from [" + defaultMappingLocation + "]", e);
|
throw new MapperException("Failed to load default mapping source from [" + defaultMappingLocation + "]", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug("using dynamic[{}], default mapping: default_mapping_location[{}], loaded_from[{}] and source[{}]", dynamic, defaultMappingLocation, defaultMappingUrl, defaultMappingSource);
|
logger.debug("using dynamic[{}], default mapping: default_mapping_location[{}], loaded_from[{}] and source[{}]", dynamic, defaultMappingLocation, defaultMappingUrl, defaultMappingSource);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue