diff --git a/sonar/config.py b/sonar/config.py index 336caece..e1ad7952 100644 --- a/sonar/config.py +++ b/sonar/config.py @@ -44,7 +44,8 @@ def _(x): BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich' #: Other supported languages (do not include the default language in list). I18N_LANGUAGES = [ - ('fr', _('French')) + ('fr', _('French')), + ('de', _('German')) ] # Base templates @@ -179,6 +180,7 @@ def _(x): SEARCH_UI_JSTEMPLATE_SELECT_BOX = 'templates/documents/search_ui/'\ 'select_box.html' SEARCH_UI_JSTEMPLATE_LOADING = 'templates/documents/search_ui/loading.html' +SEARCH_UI_JSTEMPLATE_FACETS = 'templates/documents/search_ui/facets.html' SECURITY_LOGIN_USER_TEMPLATE = 'sonar/accounts/login.html' SECURITY_FORGOT_PASSWORD_TEMPLATE = 'sonar/accounts/forgot_password.html' @@ -265,13 +267,48 @@ def _(x): RECORDS_REST_FACETS = { 'documents': dict( + aggs=dict( + institution=dict(terms=dict(field='institution.pid')), + language=dict(terms=dict(field='languages.language')), + author=dict(terms=dict(field='facet_authors')), + subject=dict(terms=dict(field='facet_subjects')) + ), filters={ - _('institution'): terms_filter('institution.pid') + _('institution'): terms_filter('institution.pid'), + _('language'): terms_filter('languages.language'), + _('author'): terms_filter('facet_authors'), + _('subject'): terms_filter('facet_subjects'), } ) } """REST search facets.""" +RECORDS_REST_SORT_OPTIONS = dict( + documents=dict( + bestmatch=dict( + title=_('Best match'), + fields=['_score'], + default_order='desc', + order=2, + ), + mostrecent=dict( + title=_('Most recent'), + fields=['-_created'], + default_order='asc', + order=1, + ), + ) +) +"""Setup sorting options.""" + +RECORDS_REST_DEFAULT_SORT = dict( + documents=dict( + query='bestmatch', + noquery='mostrecent', + ), +) +"""Set default sorting options.""" + SONAR_ENDPOINTS_ENABLED = True """Enable/disable automatic endpoint registration.""" diff --git a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py index 5753767c..19ee78c1 100644 --- a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py +++ b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py @@ -380,7 +380,6 @@ def marc21_to_is_part_of(self, key, value): @marc21tojson.over('subjects', '^6....') -@utils.for_each_value @utils.ignore_value def marc21_to_subjects(self, key, value): """Get subjects. @@ -388,4 +387,4 @@ def marc21_to_subjects(self, key, value): subjects: 6xx [duplicates could exist between several vocabularies, if possible deduplicate] """ - return value.get('a') + return value.get('a').split(' ; ') diff --git a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json index f61046a2..77ff0583 100644 --- a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json +++ b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json @@ -21,6 +21,9 @@ "type": "text", "copy_to": "facet_subjects" }, + "facet_subjects": { + "type": "keyword" + }, "identifiers": { "type": "object", "properties": { @@ -50,10 +53,14 @@ "type": "object", "properties": { "name": { - "type": "text" + "type": "text", + "copy_to": "facet_authors" } } }, + "facet_authors": { + "type": "keyword" + }, "extent": { "type": "keyword" }, @@ -67,7 +74,7 @@ "type": "keyword" }, "name": { - "type": "text" + "type": "keyword" } } }, diff --git a/sonar/modules/documents/static/templates/documents/search_ui/facets.html b/sonar/modules/documents/static/templates/documents/search_ui/facets.html new file mode 100644 index 00000000..b82d51e8 --- /dev/null +++ b/sonar/modules/documents/static/templates/documents/search_ui/facets.html @@ -0,0 +1,45 @@ +