Class LastNAggregation

java.lang.Object
ca.uhn.fhir.jpa.dao.search.LastNAggregation

public class LastNAggregation extends Object
Builds lastN aggregation, and parse the results
  • Constructor Details

    • LastNAggregation

      public LastNAggregation(int theLastNMax, boolean theAggregateOnSubject)
  • Method Details

    • toAggregation

      public com.google.gson.JsonObject toAggregation()
      Aggregation template json.

      https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html

    • extractResourceIds

      public List<Long> extractResourceIds(@Nonnull com.google.gson.JsonObject theAggregationResult)
      Parses the JSONObject aggregation result from ES to extract observation resource ids E.g aggregation result payload
       
       {
         "doc_count_error_upper_bound": 0,
         "sum_other_doc_count": 0,
         "buckets": [
           {
             "key": "http://mycode.com|code0",
             "doc_count": 45,
             "most_recent_effective": {
               "hits": {
                 "total": {
                   "value": 45,
                   "relation": "eq"
                 },
                 "max_score": null,
                 "hits": [
                   {
                     "_index": "resourcetable-000001",
                     "_type": "_doc",
                     "_id": "48",
                     "_score": null,
                     "_source": {
                       "myId": 48
                     },
                     "sort": [
                       1643673125112
                     ]
                   }
                 ]
               }
             }
           },
           {
             "key": "http://mycode.com|code1",
             "doc_count": 30,
             "most_recent_effective": {
               "hits": {
                 "total": {
                   "value": 30,
                   "relation": "eq"
                 },
                 "max_score": null,
                 "hits": [
                   {
                     "_index": "resourcetable-000001",
                     "_type": "_doc",
                     "_id": "58",
                     "_score": null,
                     "_source": {
                       "myId": 58
                     },
                     "sort": [
                       1643673125112
                     ]
                   }
                 ]
               }
             }
           }
         ]
       }