Hi Tanveer Raihan, I believe this approach should be good with DRF too.

Since this approach uses the post_save signal, your objects will be automatically indexed into ElasticSearch whenever your DRF views save a new object.

To display an object or object list through DRF you should could let ElasticSearch search for the object(s) and then take the pk of that and retrieve those objects from your regular DB. But that seems like an unnecessary way of doing things. Instead, it would be a cleaner solution to return the ElasticSearch JSON directly through an APIView, or via retrieve() and/or list() methods in the ModelViewSet like this example.

Hope I could help!

Javascript developer. Passionate learner.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store