First of all, apply a normalized cross correlation, which is more robust to certain variations. MATLAB's xcorr function has an option to do that. Next, apply it in a sliding window fashion, where you apply the correlation as a running filter. Then, simply select the maximum peak. 

Cross-Correlation to find the similartity of songs
Is it possible to use a manually created histogram facet (or the results of its curl request) like this one in a Kibana dashboard:

{
    "query" : {
        "match_all" : {}
    },
    "facets" : {
        "histo1" : {
            "histogram" : {
                "key_script" : "doc['date'].date.minuteOfHour * factor1",
                "value_script" : "doc['num1'].value + factor2",
                "params" : {
                    "factor1" : 2,
                    "factor2" : 3
                }
            }
        }
    }
}


Thanks
