Updating nested in Elasticsearch DSL within DRF?

96 views
Skip to first unread message

Manikandan FMJ

unread,
Mar 24, 2024, 2:11:16 PMMar 24
to Django REST framework

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 } ] } }
Reply all
Reply to author
Forward
0 new messages