Skip to content

Commit

Permalink
articles: search - add country aggregation
Browse files Browse the repository at this point in the history
Signed-off-by: pamfilos <[email protected]>
  • Loading branch information
pamfilos committed Oct 19, 2023
1 parent 23157d6 commit 375bb3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions scoap3/articles/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ArticleDocumentView(BaseDocumentViewSet):
LOOKUP_QUERY_IN,
],
},
"country": "authors.affiliations.country.name"
}

faceted_search_fields = {
Expand All @@ -104,6 +105,11 @@ class ArticleDocumentView(BaseDocumentViewSet):
"facet": TermsFacet,
"enabled": True,
},
"country": {
"field": "authors.affiliations.country.name",
"facet": TermsFacet,
"enabled": True,
},
}

def get_serializer_class(self):
Expand Down
6 changes: 3 additions & 3 deletions scoap3/articles/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class ArticleDocument(Document):
}
)

authors = fields.NestedField(
authors = fields.ObjectField(
properties={
"first_name": fields.TextField(),
"last_name": fields.TextField(),
"affiliations": fields.NestedField(
"affiliations": fields.ObjectField(
properties={
"value": fields.TextField(),
"organization": fields.TextField(),
"country": fields.NestedField(
"country": fields.ObjectField(
properties={
"code": fields.TextField(),
"name": fields.KeywordField(),
Expand Down

0 comments on commit 375bb3a

Please sign in to comment.