Skip to content

Instantly share code, notes, and snippets.

@MalikRumi
Created November 17, 2017 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MalikRumi/ae9f7d974b022328233be3e9dd1f777c to your computer and use it in GitHub Desktop.
Save MalikRumi/ae9f7d974b022328233be3e9dd1f777c to your computer and use it in GitHub Desktop.
#! usr/local/bin/python3.6
# coding: utf-8
from elasticsearch.helpers import bulk
from elasticsearch import Elasticsearch
from . import models
from elasticsearch_dsl.connections import connections
from elasticsearch_dsl import DocType, Text, Date, Search
connections.create_connection()
class EntryIndex(DocType):
title = Text()
chron_date = Date()
content = Text()
category = Text()
tag = Text()
class Meta:
index = 'ktab'
def bulk_indexing():
EntryIndex.init()
es = Elasticsearch()
bulk(client=es, actions=(b.indexing() for b in
models.Entry.objects.all().iterator()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment