Find time difference between documents in search hits

Hi, I am using ES for log viewer application, how can i add new script filed(hasTimeDifference) in search hits if the time difference between current and previous log is more than specified seconds(for ex: 10 seconds)..
time difference can be found by comparing timestamp of log record.
Thanks.