Esempio n. 1
0
class Work(BaseDoc):
    title = Text(analyzer=plain_ascii, fields={'keyword': Keyword()})
    sort_title = Keyword(index=False)
    uuid = Keyword(store=True)
    medium = Text(fields={'keyword': Keyword()})
    series = Text(fields={'keyword': Keyword()})
    series_position = Keyword()
    alt_titles = Text(fields={'keyword': Keyword()})
    issued_date = DateRange(format='date_optional_time')
    created_date = DateRange(format='date_optional_time')
    is_government_document = Boolean(multi=False)

    instances = Nested(Instance)
    identifiers = Nested(Identifier)
    subjects = Nested(Subject)
    agents = Nested(Agent)
    languages = Nested(Language)

    @classmethod
    def getFields(cls):
        return [
            'uuid', 'title', 'sort_title', 'sub_title', 'medium', 'series',
            'series_position', 'date_modified', 'date_updated'
        ]

    def __dir__(self):
        return ['identifiers', 'subjects', 'agents', 'languages']

    def __repr__(self):
        return '<ESWork(title={}, uuid={})>'.format(self.title, self.uuid)

    class Index:
        name = os.environ.get('ES_INDEX', None)
Esempio n. 2
0
class Work(BaseDoc):
    title = Text(fields={'keyword': Keyword()})
    sort_title = Keyword(index=False)
    uuid = Keyword(store=True)
    medium = Text(fields={'keyword': Keyword()})
    series = Text(fields={'keyword': Keyword()})
    series_position = Keyword()
    issued = DateRange(format='date_optional_time')
    issued_display = Keyword(index=False)
    created = DateRange(format='date_optional_time')
    created_display = Keyword(index=False)
    alt_titles = Text(fields={'keyword': Keyword()})
    summary = Text()

    identifiers = Nested(Identifier)
    subjects = Nested(Subject)
    agents = Nested(Agent)
    measurements = Nested(Measurement)
    links = Nested(Link)
    instances = Nested(Instance)
    language = Nested(Language)
    rights = Nested(Rights)

    @classmethod
    def getFields(cls):
        return [
            'uuid', 'title', 'sort_title', 'sub_title', 'language', 'medium',
            'series', 'series_position', 'date_modified', 'date_updated'
        ]

    class Index:
        name = os.environ.get('ES_INDEX', None)
Esempio n. 3
0
class Rights(BaseInner):
    source = Keyword()
    license = Keyword()
    rights_statement = Text(fields={'keyword': Keyword()})
    rights_reason = Text(fields={'keyword': Keyword()})
    copyright_date = DateRange()
    copyright_date_display = Keyword(index=False)
    determination_date = DateRange()
    determination_date_display = Keyword(index=False)

    @classmethod
    def getFields(cls):
        return ['source', 'license', 'rights_statement', 'rights_reason']
Esempio n. 4
0
class Instance(BaseInner):
    title = Text(fields={'keyword': Keyword()})
    sub_title = Text(fields={'keyword': Keyword()})
    alt_titles = Text(fields={'keyword': Keyword()})
    pub_place = Text(fields={'keyword': Keyword()})
    pub_date = DateRange(format='date_optional_time')
    pub_date_display = Keyword(index=False)
    pub_date_sort = Date()
    pub_date_sort_desc = Date()
    edition = Text(fields={'keyword': Keyword()})
    edition_statement = Text(fields={'keyword': Keyword()})
    table_of_contents = Text()
    volume = Text(fields={'keyword': Keyword()})
    extent = Text()
    summary = Text()

    items = Nested(Item)
    agents = Nested(Agent)
    measurements = Nested(Measurement)
    identifiers = Nested(Identifier)
    links = Nested(Link)
    language = Nested(Language)
    rights = Nested(Rights)
    covers = Nested(Link)

    @classmethod
    def getFields(cls):
        return [
            'title', 'sub_title', 'pub_place', 'edition', 'edition_statement',
            'table_of_contents', 'langauge', 'extent', 'volume', 'summary'
        ]
Esempio n. 5
0
class Instance(BaseInner):
    title = Text(analyzer=plain_ascii, fields={'keyword': Keyword()})
    sub_title = Text(analyzer=plain_ascii, fields={'keyword': Keyword()})
    alt_titles = Text(fields={'keyword': Keyword()})
    pub_place = Text(fields={'keyword': Keyword()})
    pub_date = DateRange(format='date_optional_time')
    edition = Text(fields={'keyword': Keyword()})
    edition_statement = Text(fields={'keyword': Keyword()})
    table_of_contents = Text()
    volume = Text(fields={'keyword': Keyword()})
    extent = Text()
    summary = Text()
    formats = Keyword()
    instance_id = Integer()
    edition_id = Integer()

    agents = Nested(Agent)
    identifiers = Nested(Identifier)
    rights = Nested(Rights)
    languages = Nested(Language)

    @classmethod
    def getFields(cls):
        return [
            'id', 'edition_id', 'title', 'sub_title', 'pub_place', 'edition',
            'edition_statement', 'table_of_contents', 'extent', 'summary'
        ]

    def __dir__(self):
        return ['agents', 'identifiers', 'rights', 'languages', 'formats']

    def cleanRels(self):
        for rel in dir(self):
            if isinstance(getattr(self, rel), set):
                setattr(self, rel, list(getattr(self, rel)))
Esempio n. 6
0
class Agent(BaseInner):
    name = Text(fields={'keyword': Keyword()})
    sort_name = Keyword(index=False)
    aliases = Text(fields={'keyword': Keyword()})
    lcnaf = Keyword()
    viaf = Keyword()
    birth_date = DateRange()
    birth_display = Keyword(index=False)
    death_date = DateRange()
    death_display = Keyword(index=False)
    biography = Text()
    roles = Keyword()

    links = Nested(Link)

    @classmethod
    def getFields(cls):
        return ['name', 'sort_name', 'lcnaf', 'viaf', 'biography']
Esempio n. 7
0
class _AggregateReportDoc(Document):
    class Index:
        name = "dmarc_aggregate"

    xml_schema = Text()
    org_name = Text()
    org_email = Text()
    org_extra_contact_info = Text()
    report_id = Text()
    date_range = DateRange()
    errors = Text()
    published_policy = Object(_PublishedPolicy)
    source_ip_address = Ip()
    source_country = Text()
    source_reverse_dns = Text()
    source_Base_domain = Text()
    message_count = Integer
    disposition = Text()
    dkim_aligned = Boolean()
    spf_aligned = Boolean()
    passed_dmarc = Boolean()
    policy_overrides = Nested(_PolicyOverride)
    header_from = Text()
    envelope_from = Text()
    envelope_to = Text()
    dkim_results = Nested(_DKIMResult)
    spf_results = Nested(_SPFResult)

    def add_policy_override(self, type_, comment):
        self.policy_overrides.append(_PolicyOverride(type=type_,
                                                     comment=comment))

    def add_dkim_result(self, domain, selector, result):
        self.dkim_results.append(_DKIMResult(domain=domain,
                                             selector=selector,
                                             result=result))

    def add_spf_result(self, domain, scope, result):
        self.spf_results.append(_SPFResult(domain=domain,
                                           scope=scope,
                                           result=result))

    def save(self, ** kwargs):
        self.passed_dmarc = False
        self.passed_dmarc = self.spf_aligned or self.dkim_aligned

        return super().save(** kwargs)
Esempio n. 8
0
class PartSpec(InnerDoc):
    key = Keyword()
    # Formats: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
    date_range = DateRange(format="yyyy-MM-dd HH:mm:ss.SSS||yyy-MM-dd'T'HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss"
                                  "||yyy-MM-dd'T'HH:mm:ss||epoch_millis||epoch_second")
    geo_range = DoubleRange()
Esempio n. 9
0
class Date(BaseInner):
    date = DateRange(format='date_optional_time')
    date_type = Keyword()
Esempio n. 10
0
 class Meta:
     using = es_connection
     dynamic_templates = MetaField([
         # Can't get this to work
         # https://stackoverflow.com/questions/49740033/elasticsearch-6-copy-to-with-dynamic-index-mappings
         # {
         #     "strings":
         #         {
         #             "match_mapping_type": "string",
         #             "mapping": {
         #                 "type": "text",
         #                 "copy_all": "anytext"
         #             }
         #         }
         # },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.identifier.identifier",
                     "match_mapping_type": "string",
                     "mapping": Keyword("not_analyzed")
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.titles.title",
                     "match_mapping_type": "string",
                     "mapping": Text(fields={'raw': Keyword()}),
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.subjects.subject",
                     "match_mapping_type": "string",
                     "mapping": Text(fields={'raw': Keyword()}),
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.creators.creatorName",
                     "match_mapping_type": "string",
                     "mapping": Text(fields={'raw': Keyword()}),
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.publicationYear",
                     "match_mapping_type": "string",
                     "mapping": Integer()
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.publisher",
                     "match_mapping_type": "string",
                     "mapping": Text(fields={'raw': Keyword()}),
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.dates.date",
                     "match_mapping_type": "string",
                     "mapping": DateRange()
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.geoLocations.geoLocationBox",
                     "match_mapping_type": "string",
                     "mapping": GeoShape()
                 }
         },
         {
             "metadata_json":
                 {
                     "path_match": "metadata_json.geoLocations.geoLocationPoint",
                     "match_mapping_type": "string",
                     "mapping": GeoPoint()
                 }
         }
     ])