@@ -73,6 +73,7 @@ protected function createTargetIndex()
7373 $ payload = (new RawPayload ())
7474 ->set ('index ' , $ targetIndex )
7575 ->setIfNotEmpty ('body.settings ' , $ sourceIndexConfigurator ->getSettings ())
76+ ->setIfNotEmpty ('body.mappings._default_ ' , $ sourceIndexConfigurator ->getDefaultMapping ())
7677 ->get ();
7778
7879 ElasticClient::indices ()
@@ -115,6 +116,16 @@ protected function updateTargetIndex()
115116 $ indices ->putSettings ($ targetIndexSettingsPayload );
116117 }
117118
119+ if ($ defaultMapping = $ sourceIndexConfigurator ->getDefaultMapping ()) {
120+ $ targetIndexMappingPayload = (new RawPayload ())
121+ ->set ('index ' , $ targetIndex )
122+ ->set ('type ' , '_default_ ' )
123+ ->set ('body._default_ ' , $ defaultMapping )
124+ ->get ();
125+
126+ $ indices ->putMapping ($ targetIndexMappingPayload );
127+ }
128+
118129 $ indices ->open ($ targetIndexPayload );
119130 } catch (Exception $ exception ) {
120131 $ indices ->open ($ targetIndexPayload );
@@ -158,8 +169,7 @@ protected function updateTargetIndexMapping()
158169 $ payload = (new RawPayload ())
159170 ->set ('index ' , $ targetIndex )
160171 ->set ('type ' , $ targetType )
161- ->set ('include_type_name ' , 'true ' )
162- ->set ('body. ' . $ targetType , $ mapping )
172+ ->set ('body. ' .$ targetType , $ mapping )
163173 ->get ();
164174
165175 ElasticClient::indices ()
@@ -329,7 +339,7 @@ public function handle()
329339 $ sourceModel = $ this ->getModel ();
330340 $ sourceIndexConfigurator = $ sourceModel ->getIndexConfigurator ();
331341
332- if (!in_array (Migratable::class, class_uses_recursive ($ sourceIndexConfigurator ))) {
342+ if (! in_array (Migratable::class, class_uses_recursive ($ sourceIndexConfigurator ))) {
333343 $ this ->error (sprintf (
334344 'The %s index configurator must use the %s trait. ' ,
335345 get_class ($ sourceIndexConfigurator ),
0 commit comments