コード例 #1
0
ファイル: documents.py プロジェクト: aag2113/allgall
class PageHit(DocType):
    doc_id = Long()
    fc_user_id = Long()
    product_id = Long()

    permissions = Long(multi=True)
    access_time = Date()
    origin_ip = Ip()
    request_type = Text()
    uri = Text()
    page_number = Long()
    is_full = Boolean()
    is_known_article = Boolean()
    is_known_product = Boolean()

    class Meta:
        index = 'hits'

    def save(self, **kwargs):
        return super(PageHit, self).save(**kwargs)

    @classmethod
    def properties(cls):
        props = PageHit._doc_type.mapping.properties.to_dict(
        )['doc']['properties'].keys()
        return [prop for prop in props]
コード例 #2
0
class Facebook(DataHead):

    group_detail_list = ['id', 'cover', 'description', 'name']
    post_extra_data = ['id', 'message', 'updated_time', 'permalink_url']

    keywords = Keyword(multi=True)
    group_name = Text()
    post_date = Date()
    extra_data = Nested()
    group_extra_data = Nested(
        properties=dict(map(lambda x: (x, Text()), group_detail_list)))
コード例 #3
0
class ArchivingArticle(ArchivingDocType):
    title = String(analyzer='snowball',
                   fields={'raw': String(index='not_analyzed')})
    body = String(analyzer='snowball')
    tags = String(index='not_analyzed')
    published_from = Date()
    lines = Integer()

    def save(self, **kwargs):
        self.lines = len(self.body.split())
        return super(ArchivingArticle, self).save(**kwargs)

    def is_published(self):
        return datetime.now() > self.published_from
コード例 #4
0
class Movie(DocType):
    title = Text(fields={'raw': {'type': 'keyword'}})
    summary = Text()
    datePublished = Date()
    creators = Keyword(multi=True)
    genres = Keyword(multi=True)
    casts = Keyword(multi=True)
    time = Integer()
    countries = Keyword(multi=True)
    plot_keywords = Keyword(multi=True)
    languages = Keyword(multi=True)
    rating = Float()
    poster = Keyword()
    suggest = Completion(analyzer=ngram_analyzer,
                         search_analyzer=analyzer('standard'))

    class Meta:
        index = 'imdb'
コード例 #5
0
    def get_es_mapping(cls):
        es_mapping = super(Topic, cls).get_es_mapping()

        es_mapping.field('title', Text(boost=1.5))
        es_mapping.field('tags', Text(boost=2.0))
        es_mapping.field('subtitle', Text())
        es_mapping.field('is_solved', Boolean())
        es_mapping.field('is_locked', Boolean())
        es_mapping.field('is_sticky', Boolean())
        es_mapping.field('pubdate', Date())
        es_mapping.field('forum_pk', Integer())

        # not indexed:
        es_mapping.field('get_absolute_url', Keyword(index=False))
        es_mapping.field('forum_title', Text(index=False))
        es_mapping.field('forum_get_absolute_url', Keyword(index=False))

        return es_mapping
コード例 #6
0
    def get_es_mapping(cls):
        es_mapping = super(Topic, cls).get_es_mapping()

        es_mapping.field("title", Text(boost=1.5))
        es_mapping.field("tags", Text(boost=2.0))
        es_mapping.field("subtitle", Text())
        es_mapping.field("is_solved", Boolean())
        es_mapping.field("is_locked", Boolean())
        es_mapping.field("is_sticky", Boolean())
        es_mapping.field("pubdate", Date())
        es_mapping.field("forum_pk", Integer())

        # not indexed:
        es_mapping.field("get_absolute_url", Keyword(index=False))
        es_mapping.field("forum_title", Text(index=False))
        es_mapping.field("forum_get_absolute_url", Keyword(index=False))

        return es_mapping
コード例 #7
0
    def get_es_mapping(cls):
        es_mapping = super(Post, cls).get_es_mapping()

        es_mapping.field('text_html', Text())
        es_mapping.field('is_useful', Boolean())
        es_mapping.field('is_visible', Boolean())
        es_mapping.field('position', Integer())
        es_mapping.field('like_dislike_ratio', Float())
        es_mapping.field('pubdate', Date())
        es_mapping.field('forum_pk', Integer())
        es_mapping.field('topic_pk', Integer())

        # not indexed:
        es_mapping.field('get_absolute_url', Keyword(index=False))
        es_mapping.field('topic_title', Text(index=False))
        es_mapping.field('forum_title', Text(index=False))
        es_mapping.field('forum_get_absolute_url', Keyword(index=False))

        return es_mapping
コード例 #8
0
    def get_es_mapping(cls):
        es_mapping = super(Post, cls).get_es_mapping()

        es_mapping.field("text_html", Text())
        es_mapping.field("is_useful", Boolean())
        es_mapping.field("is_visible", Boolean())
        es_mapping.field("position", Integer())
        es_mapping.field("like_dislike_ratio", Float())
        es_mapping.field("pubdate", Date())
        es_mapping.field("forum_pk", Integer())
        es_mapping.field("topic_pk", Integer())

        # not indexed:
        es_mapping.field("get_absolute_url", Keyword(index=False))
        es_mapping.field("topic_title", Text(index=False))
        es_mapping.field("forum_title", Text(index=False))
        es_mapping.field("forum_get_absolute_url", Keyword(index=False))

        return es_mapping