@@ -78,14 +78,23 @@ public void testNoDocs() throws IOException {
78
78
});
79
79
}
80
80
81
- public void testFieldMissing () throws IOException {
81
+ public void testUnmapped () throws IOException {
82
82
testCase (new MatchAllDocsQuery (), "wrong_field" , randomPrecision (), null , geoGrid -> {
83
83
assertEquals (0 , geoGrid .getBuckets ().size ());
84
84
}, iw -> {
85
85
iw .addDocument (Collections .singleton (new LatLonDocValuesField (FIELD_NAME , 10D , 10D )));
86
86
});
87
87
}
88
88
89
+ public void testUnmappedMissing () throws IOException {
90
+ GeoGridAggregationBuilder builder = createBuilder ("_name" )
91
+ .field ("wrong_field" )
92
+ .missing ("53.69437,6.475031" );
93
+ testCase (new MatchAllDocsQuery (), randomPrecision (), null , geoGrid -> assertEquals (1 , geoGrid .getBuckets ().size ()),
94
+ iw -> iw .addDocument (Collections .singleton (new LatLonDocValuesField (FIELD_NAME , 10D , 10D ))), builder );
95
+
96
+ }
97
+
89
98
public void testWithSeveralDocs () throws IOException {
90
99
int precision = randomPrecision ();
91
100
int numPoints = randomIntBetween (8 , 128 );
@@ -197,6 +206,13 @@ public void testBounds() throws IOException {
197
206
private void testCase (Query query , String field , int precision , GeoBoundingBox geoBoundingBox ,
198
207
Consumer <InternalGeoGrid <T >> verify ,
199
208
CheckedConsumer <RandomIndexWriter , IOException > buildIndex ) throws IOException {
209
+ testCase (query , precision , geoBoundingBox , verify , buildIndex , createBuilder ("_name" ).field (field ));
210
+ }
211
+
212
+ private void testCase (Query query , int precision , GeoBoundingBox geoBoundingBox ,
213
+ Consumer <InternalGeoGrid <T >> verify ,
214
+ CheckedConsumer <RandomIndexWriter , IOException > buildIndex ,
215
+ GeoGridAggregationBuilder aggregationBuilder ) throws IOException {
200
216
Directory directory = newDirectory ();
201
217
RandomIndexWriter indexWriter = new RandomIndexWriter (random (), directory );
202
218
buildIndex .accept (indexWriter );
@@ -205,7 +221,6 @@ private void testCase(Query query, String field, int precision, GeoBoundingBox g
205
221
IndexReader indexReader = DirectoryReader .open (directory );
206
222
IndexSearcher indexSearcher = newSearcher (indexReader , true , true );
207
223
208
- GeoGridAggregationBuilder aggregationBuilder = createBuilder ("_name" ).field (field );
209
224
aggregationBuilder .precision (precision );
210
225
if (geoBoundingBox != null ) {
211
226
aggregationBuilder .setGeoBoundingBox (geoBoundingBox );
0 commit comments