-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
118 lines (102 loc) · 3.17 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# My site is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.
"""Default configuration."""
from __future__ import absolute_import, print_function
from invenio_indexer.api import RecordIndexer
from invenio_records_rest.facets import terms_filter
from invenio_records_rest.utils import allow_all, check_elasticsearch
from invenio_search import RecordsSearch
def _(x):
"""Identity function for string extraction."""
return x
RECORDS_REST_ENDPOINTS = {
'recid': dict(
pid_type='recid',
pid_minter='recid',
pid_fetcher='recid',
default_endpoint_prefix=True,
search_class=RecordsSearch,
indexer_class=RecordIndexer,
search_index='records',
search_type=None,
record_serializers={
'application/json': ('my_site.records.serializers'
':json_v1_response'),
'application/x-custom': ('my_site.records.serializers'
':custom_v1_response'),
},
search_serializers={
'application/json': ('my_site.records.serializers'
':json_v1_search'),
},
record_loaders={
'application/json': ('my_site.records.loaders'
':json_v1'),
},
list_route='/records/',
item_route='/records/<pid(recid):pid_value>',
default_media_type='application/json',
max_result_window=10000,
error_handlers=dict(),
create_permission_factory_imp=allow_all,
read_permission_factory_imp=check_elasticsearch,
update_permission_factory_imp=allow_all,
delete_permission_factory_imp=allow_all,
list_permission_factory_imp=allow_all
),
}
"""REST API for my-site."""
RECORDS_UI_ENDPOINTS = {
'recid': {
'pid_type': 'recid',
'route': '/records/<pid_value>',
'template': 'records/record.html',
},
}
"""Records UI for my-site."""
SEARCH_UI_JSTEMPLATE_RESULTS = 'templates/records/results.html'
"""Result list template."""
PIDSTORE_RECID_FIELD = 'id'
MY_SITE_ENDPOINTS_ENABLED = True
"""Enable/disable automatic endpoint registration."""
RECORDS_REST_FACETS = dict(
records=dict(
aggs=dict(
type=dict(terms=dict(field='type')),
keywords=dict(terms=dict(field='keywords'))
),
post_filters=dict(
type=terms_filter('type'),
keywords=terms_filter('keywords'),
)
)
)
"""Introduce searching facets."""
RECORDS_REST_SORT_OPTIONS = dict(
records=dict(
bestmatch=dict(
title=_('Best match'),
fields=['_score'],
default_order='desc',
order=1,
),
mostrecent=dict(
title=_('Most recent'),
fields=['-_created'],
default_order='asc',
order=2,
),
)
)
"""Setup sorting options."""
RECORDS_REST_DEFAULT_SORT = dict(
records=dict(
query='bestmatch',
noquery='mostrecent',
)
)
"""Set default sorting options."""