示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
def add_card_source(instance, *args, **kwargs):
    from seed.search.models import PostES
    PostES.index_post(instance)
示例#5
0
def add_card_source(instance, *args, **kwargs):
    from seed.search.models import PostES
    PostES.index_post(instance)