Skip to content

datetime fields are indexed as TAG, sortable queries fail silently #467

@elicore

Description

@elicore

redis-om-python: 0.1.2
python: 3.10

When setting a datetime Field with index=True, the field index is created as a TAG. Queries that use > or < return no data, as the query expression is evaluated to "".

This happens in both HashModel and JsonModel.

If the field is also defined with sortable=True AND the model is a JsonModel, the model definition raises a RedisModelError:

In this Preview release, TAG fields cannot be marked as sortable. Problem field: end_date. See docs: TODO

However if the model is a HashModel, no such exception is raised.

Possible solutions:

  • Store and index datetime fields as NUMERIC.
  • Index daetime fields as TEXT and apply parsetime to create a new query field for sorting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions