|
@@ -9,6 +9,8 @@ import org.elasticsearch.search.SearchHit;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
import org.elasticsearch.xpack.ml.test.SearchHitBuilder;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
import static org.hamcrest.Matchers.contains;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.is;
|
|
@@ -36,4 +38,21 @@ public class GeoPointFieldTests extends ESTestCase {
|
|
|
assertThat(geo.isMultiField(), is(false));
|
|
|
expectThrows(UnsupportedOperationException.class, () -> geo.getParentField());
|
|
|
}
|
|
|
+
|
|
|
+ public void testMissing() {
|
|
|
+ SearchHit hit = new SearchHitBuilder(42).addField("a_keyword", "bar").build();
|
|
|
+
|
|
|
+ ExtractedField geo = new GeoPointField("missing");
|
|
|
+
|
|
|
+ assertThat(geo.value(hit), equalTo(new Object[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testArray() {
|
|
|
+ SearchHit hit = new SearchHitBuilder(42).addField("geo", Arrays.asList(1, 2)).build();
|
|
|
+
|
|
|
+ ExtractedField geo = new GeoPointField("geo");
|
|
|
+
|
|
|
+ IllegalStateException e = expectThrows(IllegalStateException.class, () -> geo.value(hit));
|
|
|
+ assertThat(e.getMessage(), equalTo("Unexpected values for a geo_point field: [1, 2]"));
|
|
|
+ }
|
|
|
}
|