File tree Expand file tree Collapse file tree 4 files changed +20
-44
lines changed 
spring-data-opensearch/src 
main/java/org/opensearch/data/client 
test/java/org/opensearch/data/client/core/aggregation Expand file tree Collapse file tree 4 files changed +20
-44
lines changed Original file line number Diff line number Diff line change 1313
1414/** 
1515 * Scripted field 
16+  * 
1617 * @since 0.1 
1718 */ 
18- public  class  ScriptField  {
19- 
20-     private  final  String  fieldName ;
21-     private  final  Script  script ;
22- 
23-     public  ScriptField (String  fieldName , Script  script ) {
24-         this .fieldName  = fieldName ;
25-         this .script  = script ;
26-     }
27- 
28-     public  String  fieldName () {
29-         return  fieldName ;
30-     }
19+ public  record  ScriptField (String  fieldName , Script  script ) {
3120
32-     public  Script  script () {
33-         return  script ;
34-     }
3521}
Original file line number Diff line number Diff line change 1818import  org .opensearch .client .opensearch ._types .aggregations .Aggregate ;
1919
2020/** 
21-  * Class to combine an OpenSearch {@link org.opensearch.client.opensearch._types.aggregations.Aggregate} with its 
22-  * name. Necessary as the OpenSearch Aggregate does not know its name. 
21+  * Class to combine an OpenSearch {@link Aggregate} with its name. Necessary as the OpenSearch Aggregate does not know its name. 
2322 * 
2423 * @author Peter-Josef Meisch 
2524 * @since 4.4 
2625 */ 
27- public  class  Aggregation  {
28- 
29-     private  final  String  name ;
30-     private  final  Aggregate  aggregate ;
31- 
32-     public  Aggregation (String  name , Aggregate  aggregate ) {
33-         this .name  = name ;
34-         this .aggregate  = aggregate ;
35-     }
26+ public  record  Aggregation (String  name , Aggregate  aggregate ) {
3627
28+     /** 
29+      * @deprecated Use {@link #name()} instead 
30+      */ 
31+     @ Deprecated 
3732    public  String  getName () {
38-         return  name ;
33+         return  name () ;
3934    }
4035
36+     /** 
37+      * @deprecated Use {@link #aggregate()} instead 
38+      */ 
39+     @ Deprecated 
4140    public  Aggregate  getAggregate () {
42-         return  aggregate ;
41+         return  aggregate () ;
4342    }
4443}
Original file line number Diff line number Diff line change 1818import  org .springframework .data .elasticsearch .core .AggregationContainer ;
1919
2020/** 
21-  * {@link AggregationContainer} for a {@link Aggregation} that holds OpenEearch data. 
21+  * {@link AggregationContainer} for a {@link Aggregation} that holds OpenSearch data. 
22+  * 
2223 * @author Peter-Josef Meisch 
2324 * @since 4.4 
2425 */ 
25- public  class  OpenSearchAggregation  implements  AggregationContainer <Aggregation > {
26- 
27-     private  final  Aggregation  aggregation ;
28- 
29-     public  OpenSearchAggregation (Aggregation  aggregation ) {
30-         this .aggregation  = aggregation ;
31-     }
26+ public  record  OpenSearchAggregation (Aggregation  aggregation ) implements  AggregationContainer <Aggregation > {
3227
33-     @ Override 
34-     public  Aggregation  aggregation () {
35-         return  aggregation ;
36-     }
3728}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ protected void assertThatAggsHasResult(AggregationsContainer<?> aggregationsCont
5454        List <OpenSearchAggregation > aggregations  = ((OpenSearchAggregations ) aggregationsContainer ).aggregations ();
5555        List <String > aggNames  = aggregations .stream () // 
5656                .map (OpenSearchAggregation ::aggregation ) // 
57-                 .map (org .opensearch .data .client .osc .Aggregation ::getName ) // 
57+                 .map (org .opensearch .data .client .osc .Aggregation ::name ) // 
5858                .collect (Collectors .toList ());
5959        assertThat (aggNames ).contains (aggsName );
6060
@@ -77,8 +77,8 @@ protected void assertThatPipelineAggsAreCorrect(
7777            AggregationsContainer <?> aggregationsContainer , String  aggsName , String  pipelineAggsName ) {
7878        Map <String , Aggregate > aggregates  = ((OpenSearchAggregations ) aggregationsContainer ).aggregations ().stream () // 
7979                .map (OpenSearchAggregation ::aggregation ) // 
80-                 .collect (Collectors .toMap (org .opensearch .data .client .osc .Aggregation ::getName ,
81-                         org .opensearch .data .client .osc .Aggregation ::getAggregate ));
80+                 .collect (Collectors .toMap (org .opensearch .data .client .osc .Aggregation ::name ,
81+                         org .opensearch .data .client .osc .Aggregation ::aggregate ));
8282
8383        assertThat (aggregates ).containsKey (aggsName );
8484        Aggregate  aggregate  = aggregates .get (pipelineAggsName );
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments