2020package org .elasticsearch .index .mapper ;
2121
2222import org .apache .lucene .index .IndexableField ;
23- import org .apache .lucene .util .BytesRef ;
2423import org .elasticsearch .Version ;
2524import org .elasticsearch .cluster .metadata .IndexMetaData ;
2625import org .elasticsearch .common .Strings ;
@@ -132,12 +131,6 @@ public void testExternalValuesWithMultifield() throws Exception {
132131 .startObject ("field" )
133132 .field ("type" , "text" )
134133 .field ("store" , true )
135- .startObject ("fields" )
136- .startObject ("raw" )
137- .field ("type" , "keyword" )
138- .field ("store" , true )
139- .endObject ()
140- .endObject ()
141134 .endObject ()
142135 .endObject ()
143136 .endObject ()
@@ -164,87 +157,5 @@ public void testExternalValuesWithMultifield() throws Exception {
164157 IndexableField field = doc .rootDoc ().getField ("field.field" );
165158 assertThat (field , notNullValue ());
166159 assertThat (field .stringValue (), is ("foo" ));
167-
168- IndexableField raw = doc .rootDoc ().getField ("field.field.raw" );
169-
170- assertThat (raw , notNullValue ());
171- assertThat (raw .binaryValue (), is (new BytesRef ("foo" )));
172-
173- assertWarnings ("At least one multi-field, [field], was " +
174- "encountered that itself contains a multi-field. Defining multi-fields within a multi-field is deprecated and will " +
175- "no longer be supported in 8.0. To resolve the issue, all instances of [fields] that occur within a [fields] block " +
176- "should be removed from the mappings, either by flattening the chained [fields] blocks into a single level, or " +
177- "switching to [copy_to] if appropriate." );
178- }
179-
180- public void testExternalValuesWithMultifieldTwoLevels () throws Exception {
181- IndexService indexService = createIndex ("test" );
182- Map <String , Mapper .TypeParser > mapperParsers = new HashMap <>();
183- mapperParsers .put (ExternalMapperPlugin .EXTERNAL , new ExternalMapper .TypeParser (ExternalMapperPlugin .EXTERNAL , "foo" ));
184- mapperParsers .put (ExternalMapperPlugin .EXTERNAL_BIS , new ExternalMapper .TypeParser (ExternalMapperPlugin .EXTERNAL , "bar" ));
185- mapperParsers .put (TextFieldMapper .CONTENT_TYPE , new TextFieldMapper .TypeParser ());
186- MapperRegistry mapperRegistry = new MapperRegistry (mapperParsers , Collections .emptyMap (), MapperPlugin .NOOP_FIELD_FILTER );
187-
188- Supplier <QueryShardContext > queryShardContext = () -> {
189- return indexService .newQueryShardContext (0 , null , () -> { throw new UnsupportedOperationException (); }, null );
190- };
191- DocumentMapperParser parser = new DocumentMapperParser (indexService .getIndexSettings (), indexService .mapperService (),
192- indexService .xContentRegistry (), indexService .similarityService (), mapperRegistry , queryShardContext );
193-
194- DocumentMapper documentMapper = parser .parse ("type" , new CompressedXContent (
195- Strings
196- .toString (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
197- .startObject ("field" )
198- .field ("type" , ExternalMapperPlugin .EXTERNAL )
199- .startObject ("fields" )
200- .startObject ("field" )
201- .field ("type" , "text" )
202- .startObject ("fields" )
203- .startObject ("generated" )
204- .field ("type" , ExternalMapperPlugin .EXTERNAL_BIS )
205- .endObject ()
206- .startObject ("raw" )
207- .field ("type" , "text" )
208- .endObject ()
209- .endObject ()
210- .endObject ()
211- .startObject ("raw" )
212- .field ("type" , "text" )
213- .endObject ()
214- .endObject ()
215- .endObject ()
216- .endObject ().endObject ().endObject ())));
217-
218- ParsedDocument doc = documentMapper .parse (new SourceToParse ("test" , "type" , "1" , BytesReference
219- .bytes (XContentFactory .jsonBuilder ()
220- .startObject ()
221- .field ("field" , "1234" )
222- .endObject ()),
223- XContentType .JSON ));
224-
225- assertThat (doc .rootDoc ().getField ("field.bool" ), notNullValue ());
226- assertThat (doc .rootDoc ().getField ("field.bool" ).stringValue (), is ("T" ));
227-
228- assertThat (doc .rootDoc ().getField ("field.point" ), notNullValue ());
229-
230- assertThat (doc .rootDoc ().getField ("field.shape" ), notNullValue ());
231-
232- assertThat (doc .rootDoc ().getField ("field.field" ), notNullValue ());
233- assertThat (doc .rootDoc ().getField ("field.field" ).stringValue (), is ("foo" ));
234-
235- assertThat (doc .rootDoc ().getField ("field.field.generated.generated" ), notNullValue ());
236- assertThat (doc .rootDoc ().getField ("field.field.generated.generated" ).stringValue (), is ("bar" ));
237-
238- assertThat (doc .rootDoc ().getField ("field.field.raw" ), notNullValue ());
239- assertThat (doc .rootDoc ().getField ("field.field.raw" ).stringValue (), is ("foo" ));
240-
241- assertThat (doc .rootDoc ().getField ("field.raw" ), notNullValue ());
242- assertThat (doc .rootDoc ().getField ("field.raw" ).stringValue (), is ("foo" ));
243-
244- assertWarnings ("At least one multi-field, [field], was " +
245- "encountered that itself contains a multi-field. Defining multi-fields within a multi-field is deprecated and will " +
246- "no longer be supported in 8.0. To resolve the issue, all instances of [fields] that occur within a [fields] block " +
247- "should be removed from the mappings, either by flattening the chained [fields] blocks into a single level, or " +
248- "switching to [copy_to] if appropriate." );
249160 }
250161}
0 commit comments