Skip to content

Commit

Permalink
Implement WithFieldName interface in ValuesSourceAggregationBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 committed Sep 12, 2024
1 parent 2e98df3 commit 57dbbd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.query.WithFieldName;
import org.opensearch.script.Script;
import org.opensearch.search.aggregations.AbstractAggregationBuilder;
import org.opensearch.search.aggregations.AggregationInitializationException;
Expand All @@ -57,7 +58,9 @@
*
* @opensearch.internal
*/
public abstract class ValuesSourceAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>> extends AbstractAggregationBuilder<AB> {
public abstract class ValuesSourceAggregationBuilder<AB extends ValuesSourceAggregationBuilder<AB>> extends AbstractAggregationBuilder<AB>
implements
WithFieldName {

public static <T> void declareFields(
AbstractObjectParser<? extends ValuesSourceAggregationBuilder<?>, T> objectParser,
Expand Down Expand Up @@ -292,6 +295,11 @@ public String field() {
return field;
}

@Override
public String fieldName() {
return field();
}

/**
* Sets the script to use for this aggregation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.opensearch.index.query.QueryRewriteContext;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.query.QueryShardException;
import org.opensearch.index.query.WithFieldName;
import org.opensearch.search.DocValueFormat;
import org.opensearch.search.MultiValueMode;
import org.opensearch.search.SearchSortValuesAndFormats;
Expand All @@ -86,7 +87,7 @@
*
* @opensearch.internal
*/
public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> {
public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> implements WithFieldName {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(FieldSortBuilder.class);

public static final String NAME = "field_sort";
Expand Down Expand Up @@ -184,6 +185,11 @@ public String getFieldName() {
return this.fieldName;
}

@Override
public String fieldName() {
return getFieldName();
}

/**
* Sets the value when a field is missing in a doc. Can also be set to {@code _last} or
* {@code _first} to sort missing last or first respectively.
Expand Down

0 comments on commit 57dbbd0

Please sign in to comment.