[Mapper] Using default=null for _timestamp field creates a index loss on restart
Step to reproduce: * Create new index and type. ``` DELETE new_index PUT new_index { "mappings": { "power": { "_timestamp" : { "enabled" : true, "default": null } } } } ``` * Add a document ``` PUT new_index/power/1 { "foo": "bar" } ``` * Restart cluster ... and **index is missing**... ``` GET new_index ``` Gives IndexMissingException Closes #9223. (cherry picked from commit e654a2c) (cherry picked from commit aef3bc2)
This commit is contained in:
parent
48bc132927
commit
be1610ba63
|
@ -354,7 +354,7 @@ public class MappingMetaData {
|
|||
path = fieldNode.toString();
|
||||
} else if (fieldName.equals("format")) {
|
||||
format = fieldNode.toString();
|
||||
} else if (fieldName.equals("default")) {
|
||||
} else if (fieldName.equals("default") && fieldNode != null) {
|
||||
defaultTimestamp = fieldNode.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -632,6 +632,22 @@ public class TimestampMappingTests extends ElasticsearchSingleNodeTest {
|
|||
assertThat(mergeResult.hasConflicts(), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for issue #9223
|
||||
*/
|
||||
@Test
|
||||
public void testInitMappers() throws IOException {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("_timestamp")
|
||||
.field("enabled", true)
|
||||
.field("default", (String) null)
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
// This was causing a NPE
|
||||
new MappingMetaData(new CompressedString(mapping));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergePaths() throws Exception {
|
||||
String[] possiblePathValues = {"some_path", "anotherPath", null};
|
||||
|
|
Loading…
Reference in New Issue