def handle(self, *args, **options): es = connections.get_connection() self.stdout.write('Deleting all the indices') es.indices.delete('blog-search') es.indices.create('blog-search', settings.ES_INDICES_SETTINGS) for post in Post.objects.all(): PostES.index_post(post)
def get(self, request): q = request.GET.get('q') search = PostES.search() if q: search = search.query(PostES.get_match_qs(q)) posts = search.execute() response = { 'posts': { 'count': posts.hits.total, 'objects': self.serialize_response_objects(posts) }, } return Response(response)
def add_card_source(instance, *args, **kwargs): from seed.search.models import PostES PostES.index_post(instance)