When updating nested objects in Django Rest Framework (DRF), they might be stored as objects instead of Nested, causing issues during search queries. How can I resolve this issue?
View file
profile = DetailsDocument.get(id=user_id)
profile.update(**serializer.validated_data)
profile.save()
Document file:
work_experience = Nested(
properties={
"employment_type": Keyword(),
"job_title": Text(),
"company": Text(),
"start_date": Date(),
"end_date": Date(),
"job_description": Text(),
"skills_acquired": Keyword(multi=True),
"visibility": Boolean(),
"verified": Boolean(),
}
)
Sample JSON Payload:
{
"data": {
"type": "Profile",
"id": 19,
"attributes": {
"work_experience": [
{
"employment_type": "Permanent",
"job_title": "Software Engineer",
"company": "TechCorp Inc.",
"start_date": "2017-06-01",
"end_date": "2020-12-31",
"job_description": "Developed web applications and software solutions.",
"skills_acquired": [
"Java",
"JavaScript",
"Database Management"
],
"visibility": true,
"verified": true
}
]
}
}
}
}