Skip to content
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 @@ -39,6 +39,13 @@ public interface Aggregation extends ToXContent {
*/
String getName();

/**
* @return a string representing the type of the aggregation. This type is added to
* the aggregation name in the response, so that it can later be used by clients
* to determine type of the aggregation and parse it into the proper object.
*/
String getType();

/**
* Get the optional byte array metadata that was set on the aggregation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@ public List<PipelineAggregator> pipelineAggregators() {
return pipelineAggregators;
}

/**
* Returns a string representing the type of the aggregation. This type is added to
* the aggregation name in the response, so that it can later be used by REST clients
* to determine the internal type of the aggregation.
*/
@Override
public String getType() {
return getWriteableName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ public final Map<String, Object> getMetaData() {
return metadata;
}

/**
* Returns a string representing the type of the aggregation. This type is added to
* the aggregation name in the response, so that it can later be used by REST clients
* to determine the internal type of the aggregation.
*/
//TODO it may make sense to move getType to the Aggregation interface given that we are duplicating it in both implementations
public abstract String getType();

@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
// Concatenates the type and the name of the aggregation (ex: top_hits#foo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void assertMultiBucketsAggregation(MultiBucketsAggregation expected, M
assertTrue(expected instanceof InternalAggregation);
assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getMetaData(), actual.getMetaData());
assertEquals(((InternalAggregation) expected).getType(), ((ParsedAggregation) actual).getType());
assertEquals(expected.getType(), actual.getType());
}

protected void assertBucket(MultiBucketsAggregation.Bucket expected, MultiBucketsAggregation.Bucket actual, boolean checkOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected <P extends ParsedAggregation> P parseAndAssert(final InternalAggregati
assertEquals(aggregation.getMetaData(), parsedAggregation.getMetaData());

assertTrue(parsedAggregation instanceof ParsedAggregation);
assertEquals(aggregation.getType(), ((ParsedAggregation) parsedAggregation).getType());
assertEquals(aggregation.getType(), parsedAggregation.getType());
}

BytesReference parsedBytes = toXContent(parsedAggregation, xContentType, params, humanReadable);
Expand Down