# Java.sql.Timestamp

**URL:** <https://discuss.elastic.co/t/java-sql-timestamp/5126>\
**Category:** Elasticsearch\
**Created:** [August 11, 2011, 2:57pm UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126 "2011-08-11T14:57:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_Kriesten](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Jan\_Kriesten](https://discuss.elastic.co/u/Jan_Kriesten)\
**Post date:** [August 11, 2011, 2:57pm UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126/1 "2011-08-11T14:57:18Z")

</div>

Hi,

another small problem:

Indexing a java.sql.Timestamp works fine. The index contains

02.05.1980 13:30:00

for the field.

Creating a search using it gives the following exception:

DEBUG 16:38:45 count: [TestNode] [testindex][0], node[1], [P],  
s[STARTED]: Failed to execute [[[testindex]][doc],  
querySource[{"constant\_score":{"filter":{"numeric\_range":{"doc.timestamp\_1":{"from":"1980-04-30","to":null,"include\_lower":true,"include\_upper":true}}}}}]]  
org.elasticsearch.index.query.QueryParsingException: [testindex] Field  
[doc.timestamp\_1] is not a numeric type  
at  
org.elasticsearch.index.query.NumericRangeFilterParser.parse(NumericRangeFilterParser.java:113)  
~[elasticsearch-0.17.4.jar:na]  
[...]

Timestamp should behave as Date, right?

Best regards, --- Jan.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 11, 2011, 4:56pm UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126/2 "2011-08-11T16:56:24Z")

</div>

There isn't automatic conversion for it, you need to convert it to Date.  
Open an issue, should be simple to support it.

On Thu, Aug 11, 2011 at 5:57 PM, Jan Kriesten [kriesten@mail.footprint.de](mailto:kriesten@mail.footprint.de)wrote:

> Hi,
> 
> another small problem:
> 
> Indexing a java.sql.Timestamp works fine. The index contains
> 
> 02.05.1980 13:30:00
> 
> for the field.
> 
> Creating a search using it gives the following exception:
> 
> DEBUG 16:38:45 count: [TestNode] [testindex][0], node[1], [P],  
> s[STARTED]: Failed to execute [[[testindex]][doc],
> 
> querySource[{"constant\_score":{"filter":{"numeric\_range":{"doc.timestamp\_1":{"from":"1980-04-30","to":null,"include\_lower":true,"include\_upper":true}}}}}]]  
> org.elasticsearch.index.query.QueryParsingException: [testindex] Field  
> [doc.timestamp\_1] is not a numeric type  
> at
> 
> org.elasticsearch.index.query.NumericRangeFilterParser.parse(NumericRangeFilterParser.java:113)  
> ~[elasticsearch-0.17.4.jar:na]  
> [...]
> 
> Timestamp should behave as Date, right?
> 
> Best regards, --- Jan.

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [August 11, 2011, 5:41pm UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126/3 "2011-08-11T17:41:34Z")

</div>

Not to pile on, but there is the Calendar class, and the Joda-Time's  
DateTime object.

I doubt you want to support a lot of different classes that support  
Date/Time functions from other classes. Is there a way to register a type  
conversion implementation?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 11, 2011, 5:47pm UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126/4 "2011-08-11T17:47:10Z")

</div>

That conversion only applies when using XContentBuilder, or when providing a  
Map. I would hate to duplicate excellent work already done by other Json  
libraries (like Jackson) where you can fully control how to convert your  
domain model to json, and then just provide it to elasticsearch to index. So  
I would say that if you need to register a custom converter, then go with  
using jackson yourself.

On Thu, Aug 11, 2011 at 8:41 PM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> Not to pile on, but there is the Calendar class, and the Joda-Time's  
> DateTime object.
> 
> I doubt you want to support a lot of different classes that support  
> Date/Time functions from other classes. Is there a way to register a type  
> conversion implementation?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:57am UTC](https://discuss.elastic.co/t/java-sql-timestamp/5126/5 "2017-07-06T03:57:25Z")

</div>


