Commit 87c3e0d3 authored by 段英荣's avatar 段英荣

modify

parent cea5c194
......@@ -11,7 +11,7 @@ import sys
from libs.es import ESPerform
import trans2es.models as md
from trans2es.utils import diary_transfer
from trans2es.utils import topic_transfer
from libs.table_scan import TableSlicer,TableSlicerChunk
from trans2es.type_info import get_type_info_map,TypeInfo
......@@ -60,9 +60,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
try:
#get_data_func = diary_transfer.DiaryTransfer
#query_set = django.db.models.QuerySet(model=md.Diary,query=md.Diary.objects.all().query)
type_name_list = get_type_info_map().keys()
for type_name in type_name_list:
......
......@@ -15,7 +15,7 @@ class Command(BaseCommand):
es_obj = ESPerform()
es_cli = es_obj.get_cli()
es_obj.create_index(es_cli,"diary")
es_obj.put_index_mapping(es_cli,"diary")
es_obj.create_index(es_cli,"topic")
es_obj.put_index_mapping(es_cli=es_cli,sub_index_name="topic")
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -8,7 +8,7 @@ import logging
from libs.es import ESPerform
from django.db import models
class Diary(models.Model):
class Topic(models.Model):
class Meta:
verbose_name = u'日记'
verbose_name_plural = u'日记'
......
......@@ -12,8 +12,8 @@ import elasticsearch
import elasticsearch.helpers
import sys
from trans2es.models import diary
from trans2es.utils.diary_transfer import DiaryTransfer
from trans2es.models import topic
from trans2es.utils.topic_transfer import TopicTransfer
from libs.es import ESPerform
......@@ -236,9 +236,9 @@ def get_type_info_map():
TypeInfo(
name='topic', # 日记
type='topic',
model=diary.Diary,
query_deferred=lambda: diary.Diary.objects.all().query,
get_data_func=DiaryTransfer.get_diary_data,
model=topic.Topic,
query_deferred=lambda: topic.Topic.objects.all().query,
get_data_func=TopicTransfer.get_topic_data,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
......
......@@ -5,13 +5,13 @@ import sys
import logging
import traceback
class DiaryTransfer(object):
class TopicTransfer(object):
def __init__(self):
pass
@classmethod
def get_diary_data(cls,instance):
def get_topic_data(cls,instance):
try:
res = dict()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment