Created
November 17, 2017 17:59
-
-
Save MalikRumi/ae9f7d974b022328233be3e9dd1f777c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! 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