Using epoch timestamp for a date range query?

I currently have a few date fields that I store as longs (epoch timestamp in seconds). When searching, I simply provide a range query with another timestamp value. This works perfectly since it's just number comparison. However, when I convert these to a "date" type and try to do the same thing, the search returns documents that are outside of the range. Wondering what I'm doing wrong here. Am I not properly specifying the date format? For reference, here is what I'm using in my mapping:


When I look at my mapping, I see that Elasticsearch assigned this a format of "dateOptionalTime".

Are you passing a formatted timestamp or epoch when you do your query with the date mapped field?

No, just the long value (for example, 1436556728). I think when I use the string "1436556728" instead of the long value, that solves the issue, but it seems like ES should be able to recognize the non-string value too.