Java.sql.Timestamp


(Jan Kriesten) #1

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.


(Shay Banon) #2

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.dewrote:

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.


(James Cook) #3

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?


(Shay Banon) #4

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 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?


(system) #5