Open scheung38 opened 2 years ago
@scheung38 well you can take any library that already integrated with django (like elastic-search-dsl or haystack ) and just use it - usually they return dict-like responses (or querysets ) that you can just return with django-ninja
Hi @vitalik. This is the elasticsearch URL to query elasticsearch:
localhost:9200/address*/_search
But the Django-Ninja URL
@api.get("/address*/_search")
def query_all(request: HttpRequest, response: HttpResponse):
return response
urlpatterns = [
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path("api/", api.urls),
]
produces URL: http://127.0.0.1:8000/paf/api/address*/_search'
where my app is called 'paf', so how do we generate an API from within Ninja:
http://127.0.0.1:8000/address*/_search'
instead of the generated URL
i.e without the paf/api as that is not needed in elasticsearch
Hi @scheung38
So let me get this straight you want to have http://127.0.0.1:8000/address*/_search
instead of http://127.0.0.1:8000/paf/api/address*/_search
Trying to integrate into Django with Elasticsearch
Are there any examples of such usage, as currently I understand its usage from making APIs but not sure within the context of Elasticsearch, how does it work in making queries to Elasticsearch?