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

Make journals work with elasticsearch 2.x #428

Merged
merged 1 commit into from
Sep 21, 2016
Merged

Make journals work with elasticsearch 2.x #428

merged 1 commit into from
Sep 21, 2016

Conversation

msievers
Copy link
Contributor

Running the specs with elasticsearch 2.1.2 reveals an error in spec/chewy/index/actions_spec#413

rspec ./spec/chewy/index/actions_spec.rb:409 # Chewy::Index::Actions.reset! journaling should not eq 0

Digging into this with pry reveals the following error while executing import

{:create=>
  {{"type"=>"mapper_parsing_exception",
    "reason"=>"failed to parse [created_at]",
    "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"Invalid format: \"1474461120\" is malformed at \"20\""}}=>
    ["AVdMuzzyVa0tBwCq2J07"]}}

The problem arises because

This is ok for elasticsearch < 2, because

For elasticsearch > 2 it isn't ok, because the given epoch does not match the specified format.

My solution for this is to drop the format specification and let the mapping simply state that created_at is a date

- elasticsearch >= 2 will complain about the format, because
  `basic_date_time` is specified and epoch is given, while es < 2 will
  silently accept epoch
- removing the format should make es < 2 accept the epoch value as usual
  and let es >= 2 use its default
  `strict_date_optional_time||epoch_millis`
@pyromaniac pyromaniac merged commit f087b9f into toptal:master Sep 21, 2016
@pyromaniac
Copy link
Contributor

Thanks!

@msievers msievers deleted the es2/remove_date_format_for_journal_timestamp branch September 22, 2016 07:40
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

Successfully merging this pull request may close these issues.

2 participants