Simple date histogram?

前端 未结 2 714
逝去的感伤
逝去的感伤 2021-01-27 09:34

Viewing documents on per weekday classification? My data is in a format like this:

{\"text\": \"hi\",\"created_at\": \"2016-02-21T18:30:36.000Z\"}
相关标签:
2条回答
  • 2021-01-27 10:04

    To use a script in an aggregation the script value is not a string but another object. I think you also need to specify lang alongside file.

    "aggs": {
        "byDays": {
            "terms": {
                "script": {
                    "lang": "groovy",
                    "file": "dateConversion",
                    "params": {
                        "date_field": "created_at",
                        "format": "EEEEEE"
                    }
                }
            }
        } 
    }
    
    0 讨论(0)
  • 2021-01-27 10:08

    Some parts of my code need some modifications

    {
       "aggs": {
        "byDays": {
          "terms": {
            "script":{
              "file":"test",
            "params": {
              "date_field": "created_at",
              "format": "EEEEEE"
            }
           }
          }
        }
      }
    }
    

    And also my test.groovy code too

    Date date = new Date(doc[date_field].value);
    date.format(format); 
    
    0 讨论(0)
提交回复
热议问题