Skip to content

Commit 6e6eb36

Browse files
committed
OpenConceptLab/ocl_issues#2252 | repos facets to include repoType filter
1 parent 25d46c3 commit 6e6eb36

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

core/collections/documents.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Index:
3434
immutable = fields.KeywordField(attr='immutable')
3535
custom_validation_schema = fields.KeywordField(attr='custom_validation_schema', normalizer='lowercase')
3636
created_by = fields.KeywordField()
37+
repo_type = fields.KeywordField()
3738

3839
class Django:
3940
model = Collection
@@ -145,3 +146,7 @@ def prepare_created_by(instance):
145146
@staticmethod
146147
def prepare__canonical_url(instance):
147148
return format_url_for_search(instance.canonical_url)
149+
150+
@staticmethod
151+
def prepare_repo_type(_):
152+
return Collection.OBJECT_TYPE

core/repos/search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ class RepoFacetedSearch(CustomESFacetedSearch):
2525
'customValidationSchema': TermsFacet(field='custom_validation_schema'),
2626
'locale': TermsFacet(field='locale', size=FACET_SIZE),
2727
'owner': TermsFacet(field='owner', size=FACET_SIZE),
28-
'ownerType': TermsFacet(field='owner_type')
28+
'ownerType': TermsFacet(field='owner_type'),
29+
'repoType': TermsFacet(field='repo_type')
2930
}

core/repos/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
from core.repos.serializers import RepoListSerializer
1212

1313
es_fields = {
14+
'repo_type': {
15+
'sortable': True,
16+
'filterable': True,
17+
'facet': True,
18+
'exact': True
19+
},
1420
'source_type': {
1521
'sortable': True,
1622
'filterable': True,

core/sources/documents.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Index:
3939
property_codes = fields.ListField(fields.KeywordField())
4040
filter_codes = fields.ListField(fields.KeywordField())
4141
match_algorithm = fields.ListField(fields.KeywordField())
42+
repo_type = fields.KeywordField()
4243

4344
class Django:
4445
model = Source
@@ -185,3 +186,7 @@ def prepare_hierarchy_meaning(instance):
185186
@staticmethod
186187
def prepare__canonical_url(instance):
187188
return format_url_for_search(instance.canonical_url)
189+
190+
@staticmethod
191+
def prepare_repo_type(_):
192+
return Source.OBJECT_TYPE

0 commit comments

Comments
 (0)