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