class ArticleQuestionType(DocType): suggest = Completion(analyzer=ik_analyzer) question_id = Keyword() title = Text(analyzer="ik_max_word") content = Keyword() answer_num = Integer() source = Keyword() url = Keyword() class Meta: index = "article" doc_type = "question"
class ConferenceSeries(DocType): ConferenceSeriesId = Long(required=True) Rank = Integer(required=True) NormalizedName = Text(required=True, analyzer="standard") DisplayName = Text(required=True, analyzer="standard") PaperCount = Long() PaperFamilyCount = Long() CitationCount = Long() CreatedDate = Date(required=True) class Meta: index = 'ConferenceSeries'.lower()
class Entity(InnerDoc): """ Inner mapping for define 'entity' attribute in the main class 'Document' """ keyword = Text(fields={'raw': Keyword()}) # 'index' attribute consists of two attributes # (arrays with a mixture of datatypes are not supported in ES) index = Nested(properties={ 'indexes': Integer(multi=True), 'words': Text(fields={'raw': Keyword()}) })
class Customer(Document): full_name = Text(analyzer='snowball') email = Text(fields={'raw': Keyword()}) company_name = Text(analyzer='snowball') address = Text(analyzer='snowball') postal_code = Text(analyzer='snowball', fields={'raw': Keyword()}) city = Text(analyzer='snowball', fields={'raw': Keyword()}) country = Text(analyzer='snowball', fields={'raw': Keyword()}) total_orders = Integer() class Index: name = 'py-customers'
class Event(DocType): ip = Ip() coords = GeoPoint() learning = Boolean() total_processed = Integer() total_blocked = Integer() blocked = Boolean() cscore0 = Keyword() score0 = Integer() zone = Keyword() id = Integer() var_name = Keyword() date = Date() whitelisted = Boolean() uri = Text(fields={'raw': Keyword(index='not_analyzed')}) server = Text(fields={'raw': Keyword(index='not_analyzed')}) comments = Text(fields={'raw': Keyword(index='not_analyzed')}) vers = Text(fields={'raw': Keyword(index='not_analyzed')}) class Meta: doc_type = 'events'
class MessageCount(InnerDoc): all = Integer() count = Integer() controversial = Integer() push = Integer() boo = Integer() neutral = Integer()
class TaxRulesIndex(DocType): id = Integer() code = Text() priority = Integer() position = Integer() customer_tax_class_ids = Long() product_tax_class_ids = Long() tax_rate_ids = Long() calculate_subtotal = Boolean() rates = Object( properties={ 'id': Integer(), 'tax_country_id': Text(), 'tax_region_id': Integer(), 'tax_postcode': Text(), 'rate': Integer(), 'code': Text(), }) class Index: name = 'vue_storefront_catalog' doc_type = 'taxrule' class Meta: doc_type = "taxrule"
class BaixingDoc(Document): url = Text() # 价格 price = Integer() # 城市 city = Text() # 位置 address = Text() # 更新时间 update_date = Date() # 经纬度 location = GeoPoint() # 标题 title = Text() # 户型 house_type = Text() # 出租类型 rent_type = Text() # 装修类型 decorate = Text() # 面积 area = Float() # 朝向 orientation = Text() # 更新时间 update_date = Date() # 楼层 floor = Integer() # 最高层 top_floor = Integer() # 标签 tags = Text(multi=True) # 图片 image_urls = Text(multi=True) class Index: name = 'hrent' class Meta: doc_type = 'baixing'
class ExhibitionIndex(DocType): django_id = Integer() title = String(analyzer='snowball', fields={'raw': String(index='no')}) description = String(analyzer=html_strip) city = String(analyzer='snowball') organization = Integer() country = Integer() created_at = Date() is_active = Boolean() is_deleted = Boolean() branches = Integer(multi=True) @staticmethod def get_model(): from b24online.models import Exhibition return Exhibition @classmethod def get_queryset(cls): return cls.get_model().objects.all().select_related('country', 'organization').prefetch_related('branches') @classmethod def to_index(cls, obj): index_instance = cls( django_id=obj.pk, title=obj.title, description=obj.description, city=obj.city, organization=obj.organization.pk, is_active=obj.is_active, is_deleted=obj.is_deleted, country=obj.country.pk, created_at=obj.created_at ) index_instance.branches = list(set([item for branch in obj.branches.all() for item in branch.get_ancestors(include_self=True).values_list('pk', flat=True)])) return index_instance
class DoubanType(Document): # title = Text( # analyzer=analyzer('ik_max_word') # # ) # title_suggest = Completion(analyzer=analyzer('ik_max_word')) title = Text(analyzer=analyzer('ik_max_word'), fields={ 'suggest': Completion(analyzer=analyzer('ik_max_word')), }) original_title = Text() douban_link = Text() rating = Double() genres = Keyword() country = Keyword() lang = Keyword() year = Integer() release_at = Date() runtime = Integer() season_count = Integer() imdb = Keyword() overview = Text(analyzer="ik_smart") small_image = Text() # big_image = Text() directors = Keyword() writers = Keyword() casts = Keyword() class Index: # doc_type = 'douban' name = 'xingren' settings = { "number_of_shards": 3, }
class StationStatus(DocType): """ { "station_id":"72", "num_bikes_available":11, "num_bikes_disabled":1, "num_docks_available":27, "num_docks_disabled":0, "is_installed":1, "is_renting":1, "is_returning":1, "last_reported":1478989087, "eightd_has_available_keys":false } """ station_id = Text() location = GeoPoint() num_bikes_available = Integer() num_docks_available = Integer() num_docs_disabled = Integer() is_installed = Integer() is_renting = Integer() is_returning = Integer() last_reported = Date() eightd_has_key_dispenser = Boolean() station_name = Text(analyzer='snowball') class Meta: index = 'station_status'
class Features(DocType): """ Database entity for static features.""" pass_name = Keyword() place = Keyword() features_set = Nested( doc_class = FeaturesSet, properties = { 'numIVUsers': Integer(), 'isLoopSimplifyForm': Boolean(), 'isEmpty': Boolean(), 'numIntToFloatCast': Integer(), 'hasLoopPreheader': Boolean(), 'numTermBrBlocks': Integer(), 'latchBlockTermOpcode': Long(), 'numCalls': Integer(), 'notDuplicatable': Boolean(), 'convergent': Boolean(), 'loopSize': Integer(), 'tripCount': Integer(), 'tripMultiply': Long(), 'termByCondBr': Boolean(), 'headerAddressTaken': Boolean(), 'PHINodesInExitBlocks': Boolean() } ) class Meta: index = 'runsystemdb' def save(self, ** kwargs): return super(Features, self).save(** kwargs)
class Live(DocType): id = Integer() speaker_id = Integer() speaker_name = Text(analyzer='ik_max_word') feedback_score = Float() # 评分 topic_names = Text(analyzer='ik_max_word') # 话题标签名字 seats_taken = Integer() # 参与人数 subject = Text(analyzer='ik_max_word') # 标题 amount = Float() # 价格(RMB) description = Text(analyzer='ik_max_word') status = Boolean() # public(True)/ended(False) starts_at = Date() outline = Text(analyzer='ik_max_word') # Live内容 speaker_message_count = Integer() tag_names = Text(analyzer='ik_max_word') liked_num = Integer() topics = Keyword() live_suggest = Completion(analyzer=ik_analyzer) @property def speaker(self): return session.query(User).get(self.speaker_id) class Meta: index = 'live' def to_dict(self): d = self._d_.copy() d.update({'type': 'live', 'speaker': self.speaker}) return d @classmethod def add(cls, **kwargs): id = kwargs.pop('id', None) if id is None: return False live = cls(meta={'id': id}, **kwargs) live.save() return live
class ElapsedTimeDocument(Document): url = Text() time_taken = Integer() log_datetime = Date() type = Text(analyzer='ik_max_word') useragent = Text() class Index: name = 'performance' settings = {"number_of_shards": 1, "number_of_replicas": 0} class Meta: doc_type = 'ElapsedTime'
class Title(Document): artist = Text() title = Text() record = Text() tracknumber = Integer() length = HalfFloat() file = Text() class Index: name = 'title' def save(self, **kwargs): return super(Title, self).save(**kwargs)
class TokenTopHistoryType(DocType): symbol = Keyword() name = Keyword() address = Keyword() quantity = Float() rank = Integer() percentage = Float() timestamp = Date() transaction = Date() last_transaction = Date() class Meta: index = "token_top_history_2" doc_type = "token_top"
class ByrArticleIndex(Document): suggest = Completion(analyzer="ik_analyzer") top_section_name = Text(analyzer="ik_max_word") section_name = Text(analyzer="ik_max_word") article_title = Text(analyzer="ik_max_word") article_url = Keyword() article_createtime = Text() article_author = Text(analyzer="ik_max_word") article_content = Text(analyzer="ik_max_word") article_comment = Integer() class Index: name = 'byrbbs'
class Spider(DocType): suggest = Completion(analyzer=ik_analyzer) title = Text(analyzer="ik_max_word") content = Text(analyzer="ik_max_word") update_time = Date() url = Keyword() platform = Text(analyzer="ik_max_word") news_time = Integer() class Meta: index = "news_spider" doc_type = "tp_news"
class PaperGroup(DocType): # meta.id = hash(Year-Field-NormalizedName) Type = Keyword() NormalizedName = Text(required=True, analyzer="standard") DisplayName = Text(required=True, analyzer="standard") Year = Integer() PaperIds = Long(multi=True) Field = Text(analyzer="standard") Keywords = Text(multi=True, analyzer="standard") CreatedDate = Date(required=True) class Meta: index = "browse_paper_group"
class BlogIndex(DocType): """ BlogIndex.init(using=es_client) """ pk = Integer() title = Text(fields={'raw': Keyword()}) created_at = Date() body = Text() tags = Keyword(multi=True) is_published = Boolean() class Meta: index = 'blog'
class ArticleType(Document): # 伯乐在线文章类型 suggest = Completion(analyzer=ik_analyzer) title = Text(analyzer="ik_max_word") create_date = Date() url = Keyword() url_object_id = Keyword() front_image_url = Keyword() front_image_path = Keyword() praise_nums = Integer() comment_nums = Integer() fav_nums = Integer() tags = Text(analyzer="ik_max_word") content = Text(analyzer="ik_max_word") class Meta: # name = "jobbole" index = "jobbole" doc_type = "article" class Index: name = 'jobbole' doc_type = 'article'
class JobboleType(Document): suggest = Completion(analyzer=ik_analyzer) title = Text(analyzer="ik_max_word") create_date = Date() url = Keyword() url_object_id = Keyword() preview_img = Keyword() preview_img_path = Keyword() votes = Integer() comments = Integer() bookmarks = Integer() tags = Text(analyzer="ik_max_word") body = Text(analyzer="ik_max_word") class Index: name = "jobbole" settings = { "number_of_shards": 2, } class Meta: doc_type = "article"
class VideoIndex(DocType): django_id = Integer() title = String(analyzer='snowball', fields={'raw': String(index='no')}) content = String(analyzer=html_strip) organization = Integer() country = Integer() is_active = Boolean() is_deleted = Boolean() created_at = Date() @staticmethod def get_model(): from b24online.models import Video return Video @classmethod def get_queryset(cls): return cls.get_model().objects.all().prefetch_related( 'organization', 'organization__countries', 'country' ) @classmethod def to_index(cls, obj): index_instance = cls( django_id=obj.pk, title=obj.title, content=obj.content, organization=getattr(obj.organization, 'pk', None), is_active=obj.is_active, is_deleted=obj.is_deleted, created_at=obj.created_at ) country = obj.country if obj.country else getattr(obj.organization, 'country', None) index_instance.country = getattr(country, 'pk', None) return index_instance
class InnovationProjectIndex(DocType): django_id = Integer() name = String(analyzer='snowball', fields={'raw': String(index='no')}) description = String(analyzer=html_strip) country = Integer() organization = Integer() branches = Integer(multi=True) is_active = Boolean() is_deleted = Boolean() created_at = Date() @staticmethod def get_model(): from b24online.models import InnovationProject return InnovationProject @classmethod def get_queryset(cls): return cls.get_model().objects.all().select_related('created_by', 'created_by__profile') \ .prefetch_related('branches', 'organization', 'organization__countries') @classmethod def to_index(cls, obj): index_instance = cls( django_id=obj.pk, name=obj.name, description=obj.description, organization=obj.organization.pk if obj.organization else None, country=obj.country.pk if obj.country else None, is_active=obj.is_active, is_deleted=obj.is_deleted, created_at=obj.created_at ) index_instance.branches = list(set([item for branch in obj.branches.all() for item in branch.get_ancestors(include_self=True).values_list('pk', flat=True)])) return index_instance
class ChamberIndex(DocType): django_id = Integer() name = String(analyzer='snowball', fields={'raw': String(index='no')}) name_auto = String(analyzer=autocomplete, fields={'raw': String(index='no')}) description = String(analyzer=html_strip) countries = Integer(multi=True) is_active = Boolean() is_deleted = Boolean() created_at = Date() @staticmethod def get_model(): from b24online.models import Chamber return Chamber @classmethod def get_queryset(cls): return cls.get_model().objects.all().prefetch_related('countries') @classmethod def to_index(cls, obj): index_instance = cls( django_id=obj.pk, name=obj.name, name_auto=obj.name, description=obj.description, is_active=obj.is_active, is_deleted=obj.is_deleted, created_at=obj.created_at ) if obj.org_type != 'affiliate': countries = obj.countries.all().values_list('pk', flat=True) else: countries = obj.parent.countries.all().values_list('pk', flat=True) index_instance.countries = list(countries) return index_instance
class CmdPerf(Document): start_date = Date(default_timezone="UTC") end_date = Date(default_timezone="UTC") elapsed_time = Integer() cmd = Text() options = Text() class Index: name = "cmd_perf" def save(self, **kwargs): self.created_at = datetime.utcnow() return super().save(**kwargs)
class ArticType(DocType): suggest = Completion(analyzer=ik_analyzer) #搜索建议自动补全的功能 title = Text(analyzer="ik_max_word") create_date = Date() link_url = Keyword() #不分析 url_object_id = Keyword() front_image_url = Keyword() front_image_path = Keyword() # 点赞数 praise_num = Integer() # 评论数 comment_num = Integer() # 收藏数 fav_num = Integer() # 标签 tags = Text(analyzer="ik_max_word") # 内容 content = Text(analyzer="ik_max_word") class Meta: index = "jobbole" doc_type = 'article'
class ASPeersDoc(GenericDoc): class Meta: doc_type = "shadowserver_as_peers" peers = Integer() asnum = Integer() country = String() isp = String() domain = String() prefix = String() asname = String() # def __setattr__(self, key, value): # if key == "prefix": # value = convert_cidr(value) def __init__(self, jdata={}): GenericDoc.__init__(self) for k, v in jdata.items(): if v is None: v = {} setattr(self, k, v)
class ESSubmission(Document): recid = Integer() inspire_id = Text() version = Integer() title = Text() collaboration = Text() status = Text() creation_date = Date() last_updated = Date() data_count = Integer() participants = Nested( properties={ 'role': Text(fields={'raw': Keyword(index='true')}), 'full_name': Text() } ) coordinator = Integer() def as_custom_dict(self, exclude=None): _dict_ = vars(self) data = _dict_['_d_'] data['creation_date'] = data['creation_date'].strftime('%Y-%m-%d') data['last_updated'] = data['last_updated'].strftime('%Y-%m-%d') participants = data.get('participants', []) data['participants'] = [] for participant in participants: data['participants'].append(participant['full_name'] + ' (' + participant['role'] + ')') if exclude: for field in exclude: if field in data: del data[field] return data class Meta: index = 'submission'
class LianjiaType(DocType): suggest = Completion(analyzer=ik_analyzer) url = Keyword() lianjia_id = Keyword() residential_district_name = Text(analyzer="ik_max_word") residential_district_url = Keyword() title = Text(analyzer="ik_max_word") region = Text(analyzer="ik_max_word") region_detail = Text(analyzer="ik_max_word") address = Text(analyzer="ik_max_word") house_area = Integer() room_count = Integer() face_direction = Text(analyzer="ik_max_word") rent_price = Integer() floor = Text(analyzer="ik_max_word") publish_time = Date() total_watch_count = Integer() crwal_time = Date() class Meta: index = "lianjia" doc_type = "lianjia_house"