Group Results by Timestamp Ignoring Hours

My document mapping has a date property in the strict_date_time_no_millis format.
However, when doing an aggregation based on this property, it also uses the hours. Is it possible to perform the aggregation using only the date and ignoring the hours?

Another issue is that the field I use for aggregation is a string to store the evaluation of a sale. Ex .: G-Good, B-Bad, N-Neutral.

Is it possible to convert these letters to make an average? Ex .: G = 2, N = 1, B-0

{
    "size": 0,
    "_source": false,
    "stored_fields": "_none_",
    "aggregations": {
        "groupby": {
            "composite": {
                "size": 1000,
                "sources": [
                    {
                        "1728": {
                            "terms": {
                                "field": "sale_date",
                                "missing_bucket": true,
                                "order": "asc"
                            }
                        }
                    }
                ]
            },
            "aggregations": {
                "1790": {
                    "avg": {
                        "field": "Converted_Rating_Field"
                    }
                }
            }
        }
    }
}

Problem Solved:

{
    "size": 0,
    "_source": false,
    "stored_fields": "_none_",
    "aggs" : {
        "sales_over_time" : {
            "date_histogram" : {
                "field" : "sale_date",
                "interval" : "day",
                "format": "dd/MM/yyyy",
                "time_zone": "-0300"
            },
             "aggs": {
                "review": {
                    "avg": {
                        "script": {
                            "lang": "painless",
                            "source": "if (doc.review.value=='P'){return 1;} else if (doc.review.value=='R'){return 2;} else if (doc.review.value=='M'){return 3;} else if (doc.review.value=='B'){return 4;}else if (doc.review.value=='O'){return 5;}else{return 0;}"
                        }
                    }
                }
            }
        }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.