private static @Nullable JsonNode missingValueForType(String name) {
      switch (name) {
        case "string": // for ES2
        case "text":
        case "keyword":
          return FACTORY.textNode("__MISSING__");
        case "long":
          return FACTORY.numberNode(Long.MIN_VALUE);
        case "integer":
          return FACTORY.numberNode(Integer.MIN_VALUE);
        case "short":
          return FACTORY.numberNode(Short.MIN_VALUE);
        case "double":
          return FACTORY.numberNode(Double.MIN_VALUE);
        case "float":
          return FACTORY.numberNode(Float.MIN_VALUE);
        case "date":
          // sentinel for missing dates: 9999-12-31
          final long millisEpoch = LocalDate.of(9999, 12, 31)
                  .atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
          // by default elastic returns dates as longs
          return FACTORY.numberNode(millisEpoch);
      }

      // this is unknown type
      return null;
    }
Mapping between ES type and json value that represents
{@code missing value} during aggregations. This value can't be
{@code null} and should match type or the field (for ES long type it
also has to be json integer, for date it has to match date format or be
integer (millis epoch) etc.

<p>It is used for terms aggregations to represent SQL {@code null}.

@param name name of the type ({@code long}, {@code keyword} ...)

@return json that will be used in elastic search terms aggregation for
missing value

@see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_missing_value_13">Missing Value</a>
criteria/elasticsearch/src/org/immutables/criteria/elasticsearch/Mapping.java