Skip to content

Extend datetime formats in REST API #3529

@timvisee

Description

@timvisee

Is your feature request related to a problem? Please describe.
We recently merged #3395 which adds a datetime payload index.

Currently, the datetime parser is very strict, only allowing RFC 3339 formats in our REST API. A common format such as YYYY-MM-DD HH:MM:SS is currently not accepted.

Describe the solution you'd like
We'd like to extend datetime parsing a bit, to accept a bit more predefined formats.

More specifically, we want to support these in our REST API:

  • RFC 3339 (already supported)
  • YYYY-MM-DD'T'HH:MM:SS (without timezone or Z)
  • YYYY-MM-DD HH:MM:SS
  • YYYY-MM-DD HH:MM
  • YYYY-MM-DD

The above list is open for discussion. But as general rule, we want to prevent ambiguity.

There's probably two bits to implement this:

  • Accept these formats in the datetime index
  • Accept these formats in the datetime_range filter

Describe alternatives you've considered

  • Do not support extra formats
    We decided to not take this route in an attempt to make the API more lenient.
  • Support all formats in ElasticSearch
    There's a lot of formats, some ambiguous and uncommon, so we decided not to include any others for now.
  • Support custom formats:
    We do not want to implement this right now because it makes the whole API a lot more complex. Maybe in the future.

Additional context
The following query must succeed after implementing the above formats. Currently it fails because the format is not accepted.

POST collections/test_collection/points/scroll
{
  "limit": 10,
  "filter": {
    "must": [
      {
        "key": "updated",
        "range": {
          "gt": "2014-01-01T00:00:00"
        }
      }
    ]
  }
}

Related issue: #3531

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions