Skip to content

Commit

Permalink
Merge branch '2.x' into backport-15430-to-2.x
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Sep 20, 2024
2 parents d009780 + 4a58f54 commit 47aa079
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/delete_backport_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ on:
jobs:
delete-branch:
runs-on: ubuntu-latest
permissions:
contents: write
if: startsWith(github.event.pull_request.head.ref,'backport/')
steps:
- name: Delete merged branch
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete merged branch
uses: actions/github-script@v5
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.pull_request.head.ref}`,
})
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Offline Nodes] Adds offline-tasks library containing various interfaces to be used for Offline Background Tasks. ([#13574](https://github.com/opensearch-project/OpenSearch/pull/13574))
- Add path prefix support to hashed prefix snapshots ([#15664](https://github.com/opensearch-project/OpenSearch/pull/15664))
- [Workload Management] QueryGroup resource cancellation framework changes ([#15651](https://github.com/opensearch-project/OpenSearch/pull/15651))
- Implement WithFieldName interface in ValuesSourceAggregationBuilder & FieldSortBuilder ([#15916](https://github.com/opensearch-project/OpenSearch/pull/15916))
- Remove identity-related feature flagged code from the RestController ([#15430](https://github.com/opensearch-project/OpenSearch/pull/15430))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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 @@ -60,7 +61,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 @@ -303,6 +306,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 @@ -66,6 +66,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 @@ -87,7 +88,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 @@ -189,6 +190,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
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testNumericKeys() throws IOException {
);
assertThat(builder.getName(), equalTo("test"));
assertThat(builder.field(), equalTo("f"));
assertThat(builder.fieldName(), equalTo("f"));
assertThat(builder.ranges, equalTo(List.of(new RangeAggregator.Range("1", null, 0d))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ protected void sortFieldAssertions(FieldSortBuilder builder, SortField sortField
assertEquals(builder.order() == SortOrder.ASC ? false : true, sortField.getReverse());
if (expectedType == SortField.Type.CUSTOM) {
assertEquals(builder.getFieldName(), sortField.getField());
assertEquals(builder.fieldName(), sortField.getField());
}
assertEquals(DocValueFormat.RAW, format);
}
Expand Down

0 comments on commit 47aa079

Please sign in to comment.