@Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    builder.field("type", contentType());

    if (includeDefaults || fieldType().tree().equals(Defaults.TREE) == false) {
      builder.field(Names.TREE, fieldType().tree());
    }
    if (includeDefaults || fieldType().treeLevels() != 0) {
      builder.field(Names.TREE_LEVELS, fieldType().treeLevels());
    }
    if (includeDefaults || fieldType().precisionInMeters() != -1) {
      builder.field(
          Names.TREE_PRESISION, DistanceUnit.METERS.toString(fieldType().precisionInMeters()));
    }
    if (includeDefaults || fieldType().strategyName() != Defaults.STRATEGY) {
      builder.field(Names.STRATEGY, fieldType().strategyName());
    }
    if (includeDefaults || fieldType().distanceErrorPct() != fieldType().defaultDistanceErrorPct) {
      builder.field(Names.DISTANCE_ERROR_PCT, fieldType().distanceErrorPct());
    }
    if (includeDefaults || fieldType().orientation() != Defaults.ORIENTATION) {
      builder.field(Names.ORIENTATION, fieldType().orientation());
    }
    if (includeDefaults || fieldType().pointsOnly() != GeoShapeFieldMapper.Defaults.POINTS_ONLY) {
      builder.field(Names.STRATEGY_POINTS_ONLY, fieldType().pointsOnly());
    }
    if (includeDefaults || coerce.explicit()) {
      builder.field("coerce", coerce.value());
    }
  }
Example #2
0
 public void toXContent(XContentBuilder builder) throws IOException {
   if (requiredSize.explicit()) {
     builder.field(
         AbstractTermsParametersParser.REQUIRED_SIZE_FIELD_NAME.getPreferredName(),
         requiredSize.value());
   }
   if (shardSize.explicit()) {
     builder.field(
         AbstractTermsParametersParser.SHARD_SIZE_FIELD_NAME.getPreferredName(),
         shardSize.value());
   }
   if (minDocCount.explicit()) {
     builder.field(
         AbstractTermsParametersParser.MIN_DOC_COUNT_FIELD_NAME.getPreferredName(),
         minDocCount.value());
   }
   if (shardMinDocCount.explicit()) {
     builder.field(
         AbstractTermsParametersParser.SHARD_MIN_DOC_COUNT_FIELD_NAME.getPreferredName(),
         shardMinDocCount.value());
   }
 }
  @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);
    }
  }