From 2ca6eedf38e909cdbd9470daec19ce55061ca7c5 Mon Sep 17 00:00:00 2001 From: Ivan Brusic Date: Wed, 3 Apr 2024 16:57:48 -0700 Subject: [PATCH] Consistent naming (#11733) Signed-off-by: Ivan Brusic --- .../AdjacencyMatrixAggregationBuilder.java | 25 +++++++++++++++---- .../metrics/AdjacencyMatrixTests.java | 11 +++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java index b3d14f3763dca..c2d2069716119 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java @@ -71,8 +71,7 @@ public class AdjacencyMatrixAggregationBuilder extends AbstractAggregationBuilde private static final ParseField SEPARATOR_FIELD = new ParseField("separator"); private static final ParseField FILTERS_FIELD = new ParseField("filters"); - - public static final ParseField SHOW_ONLY_INTERSECTING = new ParseField("show_only_intersecting"); + private static final ParseField SHOW_ONLY_INTERSECTING = new ParseField("show_only_intersecting"); private List filters; private boolean showOnlyIntersecting = false; @@ -86,7 +85,7 @@ public class AdjacencyMatrixAggregationBuilder extends AbstractAggregationBuilde PARSER.declareString(AdjacencyMatrixAggregationBuilder::separator, SEPARATOR_FIELD); PARSER.declareNamedObjects(AdjacencyMatrixAggregationBuilder::setFiltersAsList, KeyedFilter.PARSER, FILTERS_FIELD); PARSER.declareBoolean( - AdjacencyMatrixAggregationBuilder::showOnlyIntersecting, + AdjacencyMatrixAggregationBuilder::setShowOnlyIntersecting, AdjacencyMatrixAggregationBuilder.SHOW_ONLY_INTERSECTING ); } @@ -147,6 +146,22 @@ public AdjacencyMatrixAggregationBuilder(String name, String separator, Map filters, + boolean showOnlyIntersecting + ) { + this(name, DEFAULT_SEPARATOR, filters, showOnlyIntersecting); + } + /** * @param name * the name of this aggregation @@ -218,7 +233,7 @@ private AdjacencyMatrixAggregationBuilder setFiltersAsList(List fil return this; } - public AdjacencyMatrixAggregationBuilder showOnlyIntersecting(boolean showOnlyIntersecting) { + public AdjacencyMatrixAggregationBuilder setShowOnlyIntersecting(boolean showOnlyIntersecting) { this.showOnlyIntersecting = showOnlyIntersecting; return this; } @@ -268,7 +283,7 @@ protected AdjacencyMatrixAggregationBuilder doRewrite(QueryRewriteContext queryS if (modified) { return new AdjacencyMatrixAggregationBuilder(name).separator(separator) .setFiltersAsList(rewrittenFilters) - .showOnlyIntersecting(showOnlyIntersecting); + .setShowOnlyIntersecting(showOnlyIntersecting); } return this; } diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/AdjacencyMatrixTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/AdjacencyMatrixTests.java index 84ab691a91e76..38e53d65a69e6 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/AdjacencyMatrixTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/AdjacencyMatrixTests.java @@ -75,6 +75,15 @@ public void testShowOnlyIntersecting() { original.put("aaa", new MatchNoneQueryBuilder()); AdjacencyMatrixAggregationBuilder builder; builder = new AdjacencyMatrixAggregationBuilder("my-agg", "&", original, true); - assertEquals(true, builder.isShowOnlyIntersecting()); + assertTrue(builder.isShowOnlyIntersecting()); + } + + public void testShowOnlyIntersectingAsFalse() { + Map original = new HashMap<>(); + original.put("bbb", new MatchNoneQueryBuilder()); + original.put("aaa", new MatchNoneQueryBuilder()); + AdjacencyMatrixAggregationBuilder builder; + builder = new AdjacencyMatrixAggregationBuilder("my-agg", original, false); + assertFalse(builder.isShowOnlyIntersecting()); } }