@Override
 protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
     throws IOException {
   super.doXContentBody(builder, includeDefaults, params);
   if (includeDefaults || pathType != Defaults.PATH_TYPE) {
     builder.field("path", pathType.name().toLowerCase(Locale.ROOT));
   }
   if (includeDefaults || fieldType().isLatLonEnabled() != Defaults.ENABLE_LATLON) {
     builder.field("lat_lon", fieldType().isLatLonEnabled());
   }
   if (includeDefaults || fieldType().isGeohashEnabled() != Defaults.ENABLE_GEOHASH) {
     builder.field("geohash", fieldType().isGeohashEnabled());
   }
   if (includeDefaults || fieldType().isGeohashPrefixEnabled() != Defaults.ENABLE_GEOHASH_PREFIX) {
     builder.field("geohash_prefix", fieldType().isGeohashPrefixEnabled());
   }
   if (fieldType().isGeohashEnabled()
       && (includeDefaults || fieldType().geohashPrecision() != Defaults.GEO_HASH_PRECISION)) {
     builder.field("geohash_precision", fieldType().geohashPrecision());
   }
   if (fieldType().isLatLonEnabled()
       && (includeDefaults
           || fieldType().latFieldType().numericPrecisionStep()
               != NumericUtils.PRECISION_STEP_DEFAULT)) {
     builder.field("precision_step", fieldType().latFieldType().numericPrecisionStep());
   }
   if (includeDefaults || fieldType().coerce != Defaults.COERCE) {
     builder.field(Names.COERCE, fieldType().coerce);
   }
   if (includeDefaults || fieldType().ignoreMalformed != Defaults.IGNORE_MALFORMED) {
     builder.field(Names.IGNORE_MALFORMED, fieldType().ignoreMalformed);
   }
 }
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);
    doXContentAnalyzers(builder, includeDefaults);

    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", true);
    }

    if (includeDefaults || positionIncrementGap != POSITION_INCREMENT_GAP_USE_ANALYZER) {
      builder.field("position_increment_gap", positionIncrementGap);
    }

    if (includeDefaults
        || fieldType().fielddata() != ((TextFieldType) defaultFieldType).fielddata()) {
      builder.field("fielddata", fieldType().fielddata());
    }
    if (fieldType().fielddata()) {
      if (includeDefaults
          || fieldType().fielddataMinFrequency() != Defaults.FIELDDATA_MIN_FREQUENCY
          || fieldType().fielddataMaxFrequency() != Defaults.FIELDDATA_MAX_FREQUENCY
          || fieldType().fielddataMinSegmentSize() != Defaults.FIELDDATA_MIN_SEGMENT_SIZE) {
        builder.startObject("fielddata_frequency_filter");
        if (includeDefaults
            || fieldType().fielddataMinFrequency() != Defaults.FIELDDATA_MIN_FREQUENCY) {
          builder.field("min", fieldType().fielddataMinFrequency());
        }
        if (includeDefaults
            || fieldType().fielddataMaxFrequency() != Defaults.FIELDDATA_MAX_FREQUENCY) {
          builder.field("max", fieldType().fielddataMaxFrequency());
        }
        if (includeDefaults
            || fieldType().fielddataMinSegmentSize() != Defaults.FIELDDATA_MIN_SEGMENT_SIZE) {
          builder.field("min_segment_size", fieldType().fielddataMinSegmentSize());
        }
        builder.endObject();
      }
    }
  }
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);

    if (includeDefaults || fieldType().nullValue() != null) {
      Object nullValue = fieldType().nullValue();
      if (nullValue != null) {
        nullValue = InetAddresses.toAddrString((InetAddress) nullValue);
      }
      builder.field("null_value", nullValue);
    }

    if (includeDefaults || ignoreMalformed.explicit()) {
      builder.field("ignore_malformed", ignoreMalformed.value());
    }
    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", false);
    }
  }
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);
    doXContentAnalyzers(builder, includeDefaults);

    if (includeDefaults || fieldType().nullValue() != null) {
      builder.field("null_value", fieldType().nullValue());
    }
    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", false);
    }

    if (includeDefaults || positionIncrementGap != POSITION_INCREMENT_GAP_USE_ANALYZER) {
      builder.field("position_increment_gap", positionIncrementGap);
    }

    if (includeDefaults || ignoreAbove != Defaults.IGNORE_ABOVE) {
      builder.field("ignore_above", ignoreAbove);
    }
  }