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

Index field looses date precision if type not explicitly set to date (and causes sync to always update all documents) #854

Open
gabriel opened this issue Aug 4, 2022 · 0 comments

Comments

@gabriel
Copy link

gabriel commented Aug 4, 2022

Expected behavior

field :updated_at should store date with microseconds, e.g. 2022-07-20T02:00:08.123456Z

Actual behavior

field :updated_at stores date with milliseconds, e.g. 2022-07-20T02:00:08.123Z
field :updated_at, type: "date" correctly stores date with microseconds

This causes chewy:sync to always show all documents as outdated (the match fails on the microsecond to millisecond comparison, unless the microseconds actually happens to be 000).

Steps to reproduce the problem

To view bug:

  • Specify index with field :updated_at.
  • rake chewy:reset
  • View a document and see it only has millisecond precision
  • rake chewy:sync (updates all documents)
  • rake chewy:sync (updates all documents again)

To view workaround:

  • Specify index with field :updated_at, type: "date".
  • rake chewy:reset
  • View a document and see it correctly has microsecond precision
  • rake chewy:sync (no updates)
  • rake chewy:sync (no updates)

Version Information

Share here essential version information such as:

  • Chewy version: 7.2.6
  • Elasticsearch version: 8.3.3
  • Ruby version: 3.1.2p20
  • Rails version: 7.0.3.1
@gabriel gabriel changed the title Index field looses date precision if type not explicitly set to date Index field looses date precision if type not explicitly set to date (and causes sync to always update all documents) Aug 4, 2022
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

1 participant