Guest User

Untitled

a guest
Jun 18th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. # python code
  2. from django.conf import settings as s
  3. from elasticsearch import Elasticsearch
  4. import graphene
  5. from graphene_django import DjangoObjectType
  6.  
  7. def elastic_connection():
  8.     pk = 54
  9.     es = Elasticsearch(hosts=s.ELASTIC)
  10.     elastic_data = es.get_source(index=s.ELASTIC_INDEX, doc_type=s.ELASTIC_DOC_TYPE, id=pk)
  11.     return elastic_data
  12.  
  13. class ElasticType(graphene.ObjectType):
  14.         id = graphene.ID()
  15.         index = graphene.String()
  16.         found = graphene.String()
  17.  
  18.  
  19. class Query(graphene.ObjectType):
  20.     elastic = graphene.List(ElasticType)
  21.    
  22.     def resolve_elastic(self, info):
  23.       return elastic_connection()
Add Comment
Please, Sign In to add comment