Search code examples
opensearch

Opensearch rollup job fails for max metric


I am creating the following rollup job on opensearch 2.1.0 , here you can see the json I use to create the rollup using a curl command.

{
  "rollup": {
    "source_index": "source_index",
    "target_index": "rollup-index", 
    "schedule": {
      "interval": {
        "period": 1,
        "unit": "Minutes"
      }
    },
    "description": "Test Rollup job",
    "enabled": true,
    "page_size": 200,
    "delay": 0,
    "continuous": true,
    "dimensions": [{
      "date_histogram": {
        "source_field": "Timestamp",
        "fixed_interval": "1d"
      }
    },
    {"terms": {"source_field": "Type"}}
                ],
                "metrics": [
                  {
                    "source_field": "Count",
                    "metrics": [
                      {"sum":{}}
                    ]
                  },
                  {
                    "source_field": "Length",
                     "metrics": [
                      {
                        "max": {},"avg":{}
                      }
                    ]
                  },
                  {
                    "source_field": "Requests",
                    "metrics": [
                      {"max":{},"avg":{}}
                    ]
                  }
                ]
  }
}

When I try to start the job it fails with

{
  "rollup-test" : {
    "rollup_metadata" : {
      "rollup_id" : "rollup-test",
      "last_updated_time" : 1661165220488,
      "continuous" : {
        "next_window_start_time" : 1651363200000,
        "next_window_end_time" : 1651449600000
      },
      "status" : "failed",
      "failure_reason" : "failed to parse field [Length.max] of type [float] in document with id 'R766Ut9LtN-y3OK12fjBGA'. Preview of field's value: '-Infinity'",
      "stats" : {
        "pages_processed" : 1,
        "documents_processed" : 125624,
        "rollups_indexed" : 0,
        "index_time_in_millis" : 0,
        "search_time_in_millis" : 3
      }
    }
  }
}

The type for Length is mapped as

"Length" : {
              "type" : "float"
            },

I can't understand why, I've used max in other rollup jobs and it always worked.


Solution

  • The problem is that not all the documents have Length. It looks like max(null) return '-Infinity' If I update all the documents to have at least Length=0 I can run the rollup job fine.