1 6
from elasticsearch_dsl import analyzer
2 6
from django_elasticsearch_dsl import Document, Index, fields
3 6
from django_elasticsearch_dsl.registries import registry
4 6
from cyborgbackup.main.models.catalogs import Catalog as catalog_models
5

6 6
catalog_index = Index('catalog')
7 6
catalog_index.settings(
8
    number_of_shards=5,
9
    number_of_replicas=0
10
)
11

12 6
html_strip = analyzer(
13
    'html_strip',
14
    tokenizer="standard",
15
    filter=["lowercase", "stop", "snowball"],
16
    char_filter=["html_strip"]
17
)
18

19

20 6
@catalog_index.doc_type
21 6
class CatalogDocument(Document):
22
    """Catalog elasticsearch document"""
23

24 6
    id = fields.TextField(
25
        analyzer=html_strip,
26
        fields={
27
            'keyword': fields.KeywordField(),
28
        }
29
    )
30 6
    path = fields.TextField(
31
        analyzer=html_strip,
32
        fields={
33
            'keyword': fields.KeywordField(),
34
        }
35
    )
36 6
    archive_name = fields.TextField(
37
        analyzer=html_strip,
38
        fields={
39
            'keyword': fields.KeywordField(),
40
        }
41
    )
42 6
    mode = fields.TextField(
43
        analyzer=html_strip,
44
        fields={
45
            'keyword': fields.TextField(analyzer='keyword'),
46
        }
47
    )
48 6
    owner = fields.TextField(
49
        analyzer=html_strip,
50
        fields={
51
            'keyword': fields.TextField(analyzer='keyword'),
52
        }
53
    )
54 6
    group = fields.TextField(
55
        analyzer=html_strip,
56
        fields={
57
            'keyword': fields.TextField(analyzer='keyword'),
58
        }
59
    )
60 6
    mtime = fields.TextField(
61
        analyzer=html_strip,
62
        fields={
63
            'keyword': fields.TextField(analyzer='keyword'),
64
        }
65
    )
66 6
    job = fields.IntegerField(attr='job_id')
67 6
    size = fields.IntegerField()
68 6
    healthy = fields.BooleanField()
69

70 6
    class Index:
71 6
        doc_type = '_doc'
72 6
        name = 'catalog'
73

74 6
    class Meta:
75 6
        model = catalog_models
76 6
        doc_type = '_doc'
77

78 6
    class Django(object):
79

80 6
        model = catalog_models

Read our documentation on viewing source code .

Loading