Can't search on nested/embedded list of JsonModels
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
I have the following schema defined
class Workspace(JsonModel):
id: str = Field(index=True)
title: str = Field(index=True)
users: List[User] = Field(index=True)
class User(EmbeddedJsonModel):
id: str = Field(index=True)
name: str = Field(index=True)
type: str = Field(index=True)
I can't find an example like this in the documentation but if I had a Workspace saved how could I search for a User associated with that Workspace. From what I understand I have to start the search on Workspace and drill down to the users list.
From the documentation on the "skill" of a Person example I assume it would look something like this, but I haven't had success getting this to work.
user = Workspace.find(Workspace.users << User(**{"name": "John Doe"})).all()
Update/Edit.
The schema update to have User not be an EmbeddedJsonModel still doesn't function as expected, and no results are found.
The Migrator created a search index for both Workspace as well as User but it's not
clear how to take advantage of the User search index because no searches return values
class Workspace(JsonModel):
id: str = Field(index=True)
title: str = Field(index=True)
users: List[User] = Field(index=True)
class Users(JsonModel):
id: str = Field(index=True)
name: str = Field(index=True)
type: str = Field(index=True)
Stored Json
{
"pk": "01GSWNGTT7WXD7NGHPN1XPGNQQ",
"id": "6",
"title": "Test Workspace",
"users": [
"0": {
"pk": "01GSWNGTT7CMACEE55FSWKCVHQ",
"id": "30",
"name": "John",
"type": "registered",
}
]
}
User.find((User.name == "John")).all()
Returns "[]"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the nested User lookup with Workspace.find(...) and the standalone User.find(...) example, then inspect the Migrator-created indexes and the search entry points. Done means searches return the expected Workspace or User records for the stored JSON, with the supported query form documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, redis
- Domain
- database, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100