public void testIgnoreUnmapped() throws IOException {
    final GeoBoundingBoxQueryBuilder queryBuilder =
        new GeoBoundingBoxQueryBuilder("unmapped").setCorners(1.0, 0.0, 0.0, 1.0);
    queryBuilder.ignoreUnmapped(true);
    QueryShardContext shardContext = createShardContext();
    Query query = queryBuilder.toQuery(shardContext);
    assertThat(query, notNullValue());
    assertThat(query, instanceOf(MatchNoDocsQuery.class));

    final GeoBoundingBoxQueryBuilder failingQueryBuilder =
        new GeoBoundingBoxQueryBuilder("unmapped").setCorners(1.0, 0.0, 0.0, 1.0);
    failingQueryBuilder.ignoreUnmapped(false);
    QueryShardException e =
        expectThrows(QueryShardException.class, () -> failingQueryBuilder.toQuery(shardContext));
    assertThat(e.getMessage(), containsString("failed to find geo_point field [unmapped]"));
  }
  @Override
  protected GeoBoundingBoxQueryBuilder doCreateTestQueryBuilder() {
    GeoBoundingBoxQueryBuilder builder = new GeoBoundingBoxQueryBuilder(GEO_POINT_FIELD_NAME);
    Rectangle box =
        RandomShapeGenerator.xRandomRectangle(
            random(), RandomShapeGenerator.xRandomPoint(random()));

    if (randomBoolean()) {
      // check the top-left/bottom-right combination of setters
      int path = randomIntBetween(0, 2);
      switch (path) {
        case 0:
          builder.setCorners(
              new GeoPoint(box.getMaxY(), box.getMinX()),
              new GeoPoint(box.getMinY(), box.getMaxX()));
          break;
        case 1:
          builder.setCorners(
              GeohashUtils.encodeLatLon(box.getMaxY(), box.getMinX()),
              GeohashUtils.encodeLatLon(box.getMinY(), box.getMaxX()));
          break;
        default:
          builder.setCorners(box.getMaxY(), box.getMinX(), box.getMinY(), box.getMaxX());
      }
    } else {
      // check the bottom-left/ top-right combination of setters
      if (randomBoolean()) {
        builder.setCornersOGC(
            new GeoPoint(box.getMinY(), box.getMinX()), new GeoPoint(box.getMaxY(), box.getMaxX()));
      } else {
        builder.setCornersOGC(
            GeohashUtils.encodeLatLon(box.getMinY(), box.getMinX()),
            GeohashUtils.encodeLatLon(box.getMaxY(), box.getMaxX()));
      }
    }

    if (randomBoolean()) {
      builder.setValidationMethod(randomFrom(GeoValidationMethod.values()));
    }

    if (randomBoolean()) {
      builder.ignoreUnmapped(randomBoolean());
    }

    builder.type(randomFrom(GeoExecType.values()));
    return builder;
  }