@@ -120,6 +120,49 @@ public boolean apply(Object input) {
120
120
}
121
121
}
122
122
123
+ @ Test
124
+ public void updateMappingWithoutType () throws Exception {
125
+ client ().admin ().indices ().prepareCreate ("test" )
126
+ .setSettings (
127
+ ImmutableSettings .settingsBuilder ()
128
+ .put ("index.number_of_shards" , 1 )
129
+ .put ("index.number_of_replicas" , 0 )
130
+ ).addMapping ("doc" , "{\" doc\" :{\" properties\" :{\" body\" :{\" type\" :\" string\" }}}}" )
131
+ .execute ().actionGet ();
132
+ client ().admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).setWaitForGreenStatus ().execute ().actionGet ();
133
+
134
+ PutMappingResponse putMappingResponse = client ().admin ().indices ().preparePutMapping ("test" ).setType ("doc" )
135
+ .setSource ("{\" properties\" :{\" date\" :{\" type\" :\" integer\" }}}" )
136
+ .execute ().actionGet ();
137
+
138
+ assertThat (putMappingResponse .isAcknowledged (), equalTo (true ));
139
+
140
+ GetMappingsResponse getMappingsResponse = client ().admin ().indices ().prepareGetMappings ("test" ).execute ().actionGet ();
141
+ assertThat (getMappingsResponse .mappings ().get ("test" ).get ("doc" ).source ().toString (),
142
+ equalTo ("{\" doc\" :{\" properties\" :{\" body\" :{\" type\" :\" string\" },\" date\" :{\" type\" :\" integer\" }}}}" ));
143
+ }
144
+
145
+ @ Test
146
+ public void updateMappingWithoutTypeMultiObjects () throws Exception {
147
+ client ().admin ().indices ().prepareCreate ("test" )
148
+ .setSettings (
149
+ ImmutableSettings .settingsBuilder ()
150
+ .put ("index.number_of_shards" , 1 )
151
+ .put ("index.number_of_replicas" , 0 )
152
+ ).execute ().actionGet ();
153
+ client ().admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).setWaitForGreenStatus ().execute ().actionGet ();
154
+
155
+ PutMappingResponse putMappingResponse = client ().admin ().indices ().preparePutMapping ("test" ).setType ("doc" )
156
+ .setSource ("{\" _source\" :{\" enabled\" :false},\" properties\" :{\" date\" :{\" type\" :\" integer\" }}}" )
157
+ .execute ().actionGet ();
158
+
159
+ assertThat (putMappingResponse .isAcknowledged (), equalTo (true ));
160
+
161
+ GetMappingsResponse getMappingsResponse = client ().admin ().indices ().prepareGetMappings ("test" ).execute ().actionGet ();
162
+ assertThat (getMappingsResponse .mappings ().get ("test" ).get ("doc" ).source ().toString (),
163
+ equalTo ("{\" doc\" :{\" _source\" :{\" enabled\" :false},\" properties\" :{\" date\" :{\" type\" :\" integer\" }}}}" ));
164
+ }
165
+
123
166
@ Test (expected = MergeMappingException .class )
124
167
public void updateMappingWithConflicts () throws Exception {
125
168
0 commit comments