예제 #1
0
class Movie(Document):
    title = Text(fields={'raw': {'type': 'keyword'}})
    film_rating = Text()
    duration = Text()
    genre = Keyword(multi=True)
    release_date = Text()
    release_date_unix_time = Float()
    imdb_ratingValue = Float()
    imdb_bestRating = Float()
    imdb_ratingCount = Float()
    description = Text()
    storyline = Text()
    poster = Text()
    trailer_img = Text()
    director = Keyword(multi=True)
    creator = Keyword(multi=True)
    writer = Keyword(multi=True)
    stars = Keyword(multi=True)
    taglines = Keyword(multi=True)
    url = Keyword()
    req_headers = Object(enabled=False)
    res_headers = Object(enabled=False)

    suggest = Completion(analyzer=ngram_analyzer,
                         search_analyzer=analyzer('standard'))

    class Index:
        name = 'imdb'
예제 #2
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
예제 #3
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
예제 #4
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
예제 #5
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
예제 #6
0
class Post(Document):
    class Meta:
        dynamic = MetaField("strict")

    title = Text()
    title_suggest = Completion()
    published = Boolean()
    category = Keyword()
    comments = Nested(Comment)

    created_at = Date()

    def add_comment(self, author, content):
        self.comments.append(
            Comment(author=author, content=content, created_at=datetime.now()))

    def save(self, **kwargs):
        self.created_at = datetime.now()
        return super().save(**kwargs)
예제 #7
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'
예제 #8
0
class MXXZjacDoc(DocType):
    caseId = Keyword()
    ctime = Keyword()
    timeStamp = Keyword()
    applicant = Keyword()
    respondent = Nested(doc_class=InnerObjectWrapper,
                        properties={
                            "name": Keyword(),
                            "certAddress": Keyword(),
                            "phone": Keyword(),
                            "email": Keyword(),
                            "otherAddress": Keyword(),
                            "idcard": Keyword(),
                            "card_front": Text(),
                            "card_nfront": Text(),
                        })

    text = """
    借款年利率:Annual interest rate of borrowing
    合同金额:Contract amount
    放款金额:Loan amount
    合同签订时间:  
    借款开始时间:Borrowing start time
    借款结束时间:End of loan time
    借款时常:Borrowing often
    借款时长单位:Borrowing time unit
    违约时间:Default time
    尚欠本金:Still owed principal
    尚欠利息:Interest owed
    仲裁协议签订时间:Arbitration agreement time
    是否分期(分批):Whether to stage (batch)
    居间方:Intermediary party
    借款用途:Use of the loan
    还款方式:Repayment
    是否涉外:Whether it is foreign-related
    """
    caseInfo = Object(doc_class=InnerObjectWrapper,
                      properties={
                          "annualInterestOfBorrowing": Float(),
                          "contractAmount": Float(),
                          "loanAmount": Float(),
                          "contractTime ": Keyword(),
                          "borrowingStartTime": Keyword(),
                          "borrowingEndTime": Keyword(),
                          "borrowingOften": Integer(),
                          "borrowingTimeUnit": Keyword(),
                          "defaultTime": Keyword(),
                          "stillOwedPrincipal": Float(),
                          "interestOwed": Float(),
                          "arbitrationAgreementTime": Keyword(),
                          "whetherStaging": Keyword(),
                          "intermediaryParty": Keyword(),
                          "usageLoan": Keyword(),
                          "repaymentWay": Keyword(),
                          "whetherForeign": Keyword(),
                      })

    contentiousAmount = Float()

    class Meta:
        index = config.ES_INDEX
        doc_type = config.ES_DOC_TYPE

    @classmethod
    def make_doc(cls, caseId, ctime, timeStamp, applicant, respondent,
                 caseInfo, contentiousAmount):
        doc_obj = cls()
        doc_obj.meta.id = caseId
        doc_obj.caseId = caseId
        doc_obj.ctime = ctime
        doc_obj.timeStamp = timeStamp
        doc_obj.applicant = applicant
        doc_obj.respondent = respondent
        doc_obj.respondent = caseInfo
        doc_obj.respondent = contentiousAmount
        doc_obj.save()
        return doc_obj.to_dict(include_meta=False)