1717import org .elasticsearch .index .mapper .MappedFieldType ;
1818
1919import java .nio .ByteOrder ;
20- import java .util .ArrayList ;
2120import java .util .Comparator ;
2221import java .util .List ;
2322import java .util .Map ;
@@ -30,10 +29,7 @@ public GeoPointFieldBlockLoaderTests(BlockLoaderTestCase.Params params) {
3029
3130 @ Override
3231 @ SuppressWarnings ("unchecked" )
33- protected Object expected (Map <String , Object > fieldMapping , Object value , TestContext testContext ) {
34- var extractedFieldValues = (ExtractedFieldValues ) value ;
35- var values = extractedFieldValues .values ();
36-
32+ protected Object expected (Map <String , Object > fieldMapping , Object values , TestContext testContext ) {
3733 var rawNullValue = fieldMapping .get ("null_value" );
3834
3935 GeoPoint nullValue ;
@@ -80,9 +76,6 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
8076 if (syntheticSourceKeep .equals ("all" )) {
8177 return exactValuesFromSource (values , nullValue , false );
8278 }
83- if (syntheticSourceKeep .equals ("arrays" ) && extractedFieldValues .documentHasObjectArrays ()) {
84- return exactValuesFromSource (values , nullValue , false );
85- }
8679
8780 // synthetic source and doc_values are present
8881 if (hasDocValues (fieldMapping , true )) {
@@ -117,61 +110,6 @@ private Object exactValuesFromSource(Object value, GeoPoint nullValue, boolean n
117110 return maybeFoldList (resultList );
118111 }
119112
120- private record ExtractedFieldValues (Object values , boolean documentHasObjectArrays ) {}
121-
122- @ Override
123- protected Object getFieldValue (Map <String , Object > document , String fieldName ) {
124- var extracted = new ArrayList <>();
125- var documentHasObjectArrays = processLevel (document , fieldName , extracted , false );
126-
127- if (extracted .size () == 1 ) {
128- return new ExtractedFieldValues (extracted .get (0 ), documentHasObjectArrays );
129- }
130-
131- return new ExtractedFieldValues (extracted , documentHasObjectArrays );
132- }
133-
134- @ SuppressWarnings ("unchecked" )
135- private boolean processLevel (Map <String , Object > level , String field , ArrayList <Object > extracted , boolean documentHasObjectArrays ) {
136- if (field .contains ("." ) == false ) {
137- var value = level .get (field );
138- processLeafLevel (value , extracted );
139- return documentHasObjectArrays ;
140- }
141-
142- var nameInLevel = field .split ("\\ ." )[0 ];
143- var entry = level .get (nameInLevel );
144- if (entry instanceof Map <?, ?> m ) {
145- return processLevel ((Map <String , Object >) m , field .substring (field .indexOf ('.' ) + 1 ), extracted , documentHasObjectArrays );
146- }
147- if (entry instanceof List <?> l ) {
148- for (var object : l ) {
149- processLevel ((Map <String , Object >) object , field .substring (field .indexOf ('.' ) + 1 ), extracted , true );
150- }
151- return true ;
152- }
153-
154- assert false : "unexpected document structure" ;
155- return false ;
156- }
157-
158- private void processLeafLevel (Object value , ArrayList <Object > extracted ) {
159- if (value instanceof List <?> l ) {
160- if (l .size () > 0 && l .get (0 ) instanceof Double ) {
161- // this must be a single point in array form
162- // we'll put it into a different form here to make our lives a bit easier while implementing `expected`
163- extracted .add (Map .of ("type" , "point" , "coordinates" , l ));
164- } else {
165- // this is actually an array of points but there could still be points in array form inside
166- for (var arrayValue : l ) {
167- processLeafLevel (arrayValue , extracted );
168- }
169- }
170- } else {
171- extracted .add (value );
172- }
173- }
174-
175113 @ SuppressWarnings ("unchecked" )
176114 private GeoPoint convert (Object value , GeoPoint nullValue , boolean needsMultifieldAdjustment ) {
177115 if (value == null ) {
0 commit comments