redis / redis/redis-om-python

EmbeddedJson fields are not able to be sorted on, even with the `sortable=True` flag

Open
#431 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.3k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Trying to do something like

result_set = Book.find( (Book.metrics.score < 3) ).sort_by("metrics.score")

will result in the error that metrics.score is not part of the model even though the find portion works as expected. Since the sort_by function requires a string to look for the - for sort order, I haven't found a way around this. Model can be found here - taken from RU 204 on JSON with OM - @simonprickett anything to add?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the example model in src/python/redis_om_search_example/model.py and reproduce the failing find and sort_by call. Trace sort_by and EmbeddedJson handling for sortable fields; done means sorting by metrics.score works without the model-field error while the existing filtering behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, redis
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.