@@ -37,7 +37,7 @@ public function initializeObject($cause)
3737 {
3838 parent ::initializeObject ($ cause );
3939 if ($ cause === ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED ) {
40- $ this ->adjustStringTypeMapping ($ this ->defaultConfigurationPerType );
40+ $ this ->migrateConfigurationForElasticVersion5 ($ this ->defaultConfigurationPerType );
4141 }
4242 }
4343
@@ -64,7 +64,7 @@ public function buildMappingInformation(Index $index)
6464 $ fullConfiguration = $ nodeType ->getFullConfiguration ();
6565 if (isset ($ fullConfiguration ['search ' ]['elasticSearchMapping ' ])) {
6666 $ fullMapping = $ fullConfiguration ['search ' ]['elasticSearchMapping ' ];
67- $ this ->adjustStringTypeMapping ($ fullMapping );
67+ $ this ->migrateConfigurationForElasticVersion5 ($ fullMapping );
6868 $ mapping ->setFullMapping ($ fullMapping );
6969 }
7070
@@ -84,7 +84,7 @@ public function buildMappingInformation(Index $index)
8484 if (isset ($ propertyConfiguration ['search ' ]) && isset ($ propertyConfiguration ['search ' ]['elasticSearchMapping ' ])) {
8585 if (is_array ($ propertyConfiguration ['search ' ]['elasticSearchMapping ' ])) {
8686 $ propertyMapping = $ propertyConfiguration ['search ' ]['elasticSearchMapping ' ];
87- $ this ->adjustStringTypeMapping ($ propertyMapping );
87+ $ this ->migrateConfigurationForElasticVersion5 ($ propertyMapping );
8888 $ mapping ->setPropertyByPath ($ propertyName , $ propertyMapping );
8989 }
9090 } elseif (isset ($ propertyConfiguration ['type ' ]) && isset ($ this ->defaultConfigurationPerType [$ propertyConfiguration ['type ' ]]['elasticSearchMapping ' ])) {
@@ -102,6 +102,45 @@ public function buildMappingInformation(Index $index)
102102 return $ mappings ;
103103 }
104104
105+ /**
106+ * @param array $mapping
107+ */
108+ protected function migrateConfigurationForElasticVersion5 (array &$ mapping )
109+ {
110+ $ this ->migrateIncludeInAllToCopyTo ($ mapping );
111+ $ this ->adjustStringTypeMapping ($ mapping );
112+ }
113+
114+ /**
115+ * include_in_all is deprecated with elasticsearch 5.x and raises
116+ * warnings on index creation
117+ *
118+ * @param array $mapping
119+ */
120+ protected function migrateIncludeInAllToCopyTo (array &$ mapping )
121+ {
122+ $ migrateIncludeInAll = function (&$ mapping ) {
123+ if (isset ($ mapping ['include_in_all ' ])) {
124+ if ((bool )$ mapping ['include_in_all ' ] === true ) {
125+ $ mapping ['copy_to ' ] = '_all ' ;
126+ }
127+ unset($ mapping ['include_in_all ' ]);
128+ }
129+ };
130+
131+ $ migrateIncludeInAll ($ mapping );
132+
133+ foreach ($ mapping as &$ item ) {
134+ if (!is_array ($ item )) {
135+ continue ;
136+ }
137+
138+ $ migrateIncludeInAll ($ mapping );
139+
140+ $ this ->migrateIncludeInAllToCopyTo ($ item );
141+ }
142+ }
143+
105144 /**
106145 * Adjust the mapping for string to text or keyword as needed.
107146 *
0 commit comments