Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _as_string output to only show when format specified #10571

Merged
merged 1 commit into from
Apr 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
builder.field(CommonFields.VALUE, count != 0 ? getValue() : null);
if (count != 0 && valueFormatter != null) {
if (count != 0 && valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(getValue()));
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void merge(InternalCardinality other) {
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
final long cardinality = getValue();
builder.field(CommonFields.VALUE, cardinality);
if (valueFormatter != null) {
if (valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(cardinality));
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
boolean hasValue = !Double.isInfinite(max);
builder.field(CommonFields.VALUE, hasValue ? max : null);
if (hasValue && valueFormatter != null) {
if (hasValue && valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(max));
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
boolean hasValue = !Double.isInfinite(min);
builder.field(CommonFields.VALUE, hasValue ? min : null);
if (hasValue && valueFormatter != null) {
if (hasValue && valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(min));
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public XContentBuilder doXContentBody(XContentBuilder builder, Params params) th
String key = String.valueOf(keys[i]);
double value = value(keys[i]);
builder.field(key, value);
if (valueFormatter != null) {
if (valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(key + "_as_string", valueFormatter.format(value));
}
}
Expand All @@ -125,7 +125,7 @@ public XContentBuilder doXContentBody(XContentBuilder builder, Params params) th
builder.startObject();
builder.field(CommonFields.KEY, keys[i]);
builder.field(CommonFields.VALUE, value);
if (valueFormatter != null) {
if (valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(value));
}
builder.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public XContentBuilder doXContentBody(XContentBuilder builder, Params params) th
builder.field(Fields.MAX, count != 0 ? max : null);
builder.field(Fields.AVG, count != 0 ? getAvg() : null);
builder.field(Fields.SUM, count != 0 ? sum : null);
if (count != 0 && valueFormatter != null) {
if (count != 0 && valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(Fields.MIN_AS_STRING, valueFormatter.format(min));
builder.field(Fields.MAX_AS_STRING, valueFormatter.format(max));
builder.field(Fields.AVG_AS_STRING, valueFormatter.format(getAvg()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected XContentBuilder otherStatsToXCotent(XContentBuilder builder, Params pa
.field(Fields.LOWER, count != 0 ? getStdDeviationBound(Bounds.LOWER) : null)
.endObject();

if (count != 0 && valueFormatter != null) {
if (count != 0 && valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(Fields.SUM_OF_SQRS_AS_STRING, valueFormatter.format(sumOfSqrs));
builder.field(Fields.VARIANCE_AS_STRING, valueFormatter.format(getVariance()));
builder.field(Fields.STD_DEVIATION_AS_STRING, getStdDeviationAsString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
builder.field(CommonFields.VALUE, sum);
if (valueFormatter != null) {
if (valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(sum));
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
builder.field(CommonFields.VALUE, value);
if (valueFormatter != null) {
if (valueFormatter != null && !(valueFormatter instanceof ValueFormatter.Raw)) {
builder.field(CommonFields.VALUE_AS_STRING, valueFormatter.format(value));
}
return builder;
Expand Down