I want to do search from android app using api build in django rest framework. Like haystack elasticsearch we can make search in html using django. Can any one tell how to use drf with elasticsearch ?
1 Answer
You should show us what you got so far
I would:
- pick one of the implementations of elasticsearch for django out there
- create a DRF-serializer class for a single search result/or the specific model class (with the fields that you need on the frontend)
- create a view that checks for a GET-parameter e.g.
?query=fooand use that to engage your search - then serialize the results and return it
4 Comments
Bhupendra Singh Chauhan
I could not understand what exactly you want me to do. Can you pls explain me with some code example. And i have written my approach can you please see it and suggest me any change.
djangonaut
So your main concern is performance? I would time the different parts of the request to find out where most time is used. Search for
python/django profiling to get started. And I would repeat the experiment on a machine with more ram/cpu available for better measurement. I would have suspected the search server to take the motherload of time... but since you say it's very fast.Bhupendra Singh Chauhan
Thanks for your help . And I haven't measured the server response time but I saw the average response time of elastic search from heroku add on console. where it was under 58 ms.
Bhupendra Singh Chauhan
I have added django profiling please see it : gist