Skip to content

Commit 9b79387

Browse files
committed
add composite sources seoperate metadata fields
1 parent b078c22 commit 9b79387

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

api/views/paginated_elastic_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get(self, request: HttpRequest) -> Response:
9191
aggregations.pop("metadata")
9292
for agg in metadata_aggregations:
9393
label: str = agg["key"]["metadata_label"]
94-
value: str = agg["key"]["metadata_value"]
94+
value: str = agg["key"].get("metadata_value", "")
9595
if label not in aggregations:
9696
aggregations[label] = {}
9797
aggregations[label][value] = agg["doc_count"]

api/views/search_dataset.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ def add_aggregations(self, search: Search) -> Search:
169169

170170
metadata_bucket = search.aggs.bucket("metadata", "nested", path="metadata")
171171
composite_sources = [
172-
{"metadata": {"terms": {"field": "metadata.label.keyword"}}}
172+
{
173+
"metadata_label": {
174+
"terms": {"field": "metadata.metadata_item.label"}
175+
}
176+
},
177+
{"metadata_value": {"terms": {"field": "metadata.value"}}},
173178
]
174179
composite_agg = A(
175180
"composite",

0 commit comments

Comments
 (0)