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

Unparseable date. java.utils.Date could not be parsed back. #34

Open
vkolotov opened this issue Nov 28, 2011 · 5 comments
Open

Unparseable date. java.utils.Date could not be parsed back. #34

vkolotov opened this issue Nov 28, 2011 · 5 comments

Comments

@vkolotov
Copy link

For some reason date filed could not be parsed back from elastic DB to an entity which has this date field.

I have very straightforward entity like:

@entity
@ElasticSearchable
class Article extends Model {

....
public String title;
....
public Date issueDate;

}

Indexing of this class performs well. But when you make query you've got following exception:

java.text.ParseException: Unparseable date: "2007-01-01T00:00:00.000Z"
at java.text.DateFormat.parse(DateFormat.java:337)
at play.modules.elasticsearch.util.ReflectionUtil.getDate(ReflectionUtil.java:520)
at play.modules.elasticsearch.util.ReflectionUtil.convertToDate(ReflectionUtil.java:502)
at play.modules.elasticsearch.util.ReflectionUtil.setFieldValue(ReflectionUtil.java:367)
at play.modules.elasticsearch.util.ReflectionUtil.setFieldValue(ReflectionUtil.java:339)
at play.modules.elasticsearch.transformer.Transformer.toSearchResults(Transformer.java:68)
at play.modules.elasticsearch.Query.fetch(Query.java:173)
at play.modules.elasticsearch.ElasticSearch.search(ElasticSearch.java:145)
at play.modules.elasticsearch.ElasticSearch.search(ElasticSearch.java:96)
at utils.SimpleQueryBuilderTest.testShouldAndMust(SimpleQueryBuilderTest.java:64)

The entity is stored in elastic DB like that:

{

_index: models_article
_type: models_article
_id: 11
_score: 1
_source: {
    identifier: 11_article
    title: very test 11 article title
    body: <div>the very 11 article body</div>
    issueDate: 2011-11-22T00:00:00.000Z
    section: 11 section
    coverStory: true
    authors: [
        Billy Gates
    ]
    editions: [ ]
    photos: [ ]
    id: 11
}

}

@bgooren
Copy link
Contributor

bgooren commented Nov 28, 2011

Which version of the module are you using?

@vkolotov
Copy link
Author

I tried both versions: head and 0.3.

@bgooren
Copy link
Contributor

bgooren commented Nov 28, 2011

Ok, just to log the result of my short search for the problem:

Felipe: any idea if the date format was changed in elasticsearch? I assume you chose this date format for a reason?

@bgooren
Copy link
Contributor

bgooren commented Dec 5, 2011

With 0.3 I cannot index a date field without an exception, so let me fix that first. I'm pretty sure it will also fix your issue.

@bgooren
Copy link
Contributor

bgooren commented Dec 5, 2011

Ok, I have fixed this by using the date formatter used by elastic search.

bgooren added a commit to bgooren/playframework-elasticsearch that referenced this issue Dec 5, 2011
@bgooren bgooren mentioned this issue Dec 5, 2011
iskra-vitaly added a commit to iskra-vitaly/playframework-elasticsearch that referenced this issue Mar 6, 2012
* org_elastic/master: (28 commits)
  0.4 release
  Add MapperTransformer
  Use AbstractFieldMapper#getFieldValue()
  Some refactoring; Mapper prefix folded into AbstractFieldMapper
  feliperazeek#32 Added a transformer which uses a mapper
  Make sure the user has not requested unknown fields
  Minor restructuring
  Made AFM#addField() non-static so we can access meta directly
  Log json for index operation
  Fix for feliperazeek#36 (Class references not cleaned up on hot reload)
  Fix for feliperazeek#38 (@onetomany causes "Type not allowed" exception)
  Fix for feliperazeek#34 (cannot parse indexed date on record retrieval)
  Upgrade to ES 0.18.5
  Fix for feliperazeek#37 (do not index @transient fields)
  Fixed elasticSearch tag path (fixes bug in _at least_ 1.2.4-RC3)
  Fixed route indentation to make file more readable
  Add support for Float conversion to ReflectionUtil
  Releasing 0.3
  setQuery(QueryBuilder) is available from es-0.17.0 (See ES issue 994)
  Log type mapping
  ...

Conflicts:
	conf/routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants