Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce configuration for returning Date object as primitives #422

Closed
costin opened this issue Apr 14, 2015 · 3 comments
Closed

Introduce configuration for returning Date object as primitives #422

costin opened this issue Apr 14, 2015 · 3 comments

Comments

@costin
Copy link
Member

costin commented Apr 14, 2015

Sometimes, returning a Date as a long or String might be preferred to that of a rich object where available. While the user can do so by implementing their own deserializer, it would be nice/convenient to have this provided out of the box.

@mgreene
Copy link

mgreene commented Apr 14, 2015

I'm not entirely sure if this is being considered or not, but it does seem that this is less of a static configuration if I'm understanding it correctly.

ES seems to allow you to write a Date value in a variety of formats. What I'm hoping for is that the interfaces between ES and processing frameworks like Hadoop and Spark will dynamically deserialize into the correct data type given the format it is stored in.

So if I have a mapping like:

"created_at": {
    "type": "date"
},
"updated_at": {
    "type": "date",
    "format": "yyyy-MM-dd"
}

and I index a long UTC millis value to created_at and a human readable date string to updated_at I would expect to get the same formats back during the deserialization process.

costin added a commit that referenced this issue Apr 25, 2015
Introduce 'es.mapping.date.rich` to allow the types from Elasticsearch
to be returned in primitive form (String or Long) vs rich objects
(such as Date or Timestamp).

Rework some of the existing readers to return a Date object instead of
a Long

relates #422
@costin
Copy link
Member Author

costin commented Apr 25, 2015

The issue has been addressed in master, the docs updated and the nightly builds published.
In short, by default, date objects are returned as rich objects (they vary depending on the library used). To get the fields as primitives (long or String depending on how they are stored), one should use es.mapping.date.rich field and configure it to false.

@costin
Copy link
Member Author

costin commented Apr 28, 2015

Closing the issue; if the problem persists please create a new one.

@costin costin closed this as completed Apr 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants