Skip to content

Commit 7d9cab4

Browse files
committed
update normalization for publisher documents
1 parent 13f101d commit 7d9cab4

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

api/views/search_unified.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ def _normalize_result(self, hit: Any) -> Dict[str, Any]:
332332
result["title"] = ""
333333
if "description" not in result:
334334
result["description"] = ""
335-
# AIModel uses created_at/updated_at
336335
if "created_at" in result:
337336
result["created"] = result["created_at"]
338337
if "updated_at" in result:
@@ -343,16 +342,20 @@ def _normalize_result(self, hit: Any) -> Dict[str, Any]:
343342
if "title" not in result:
344343
result["title"] = ""
345344
elif result["type"] == "publisher":
346-
# For publishers, use 'name' as title and handle description
347345
if "name" in result:
348346
result["title"] = result.get("name", "")
349347
if "bio" in result and result.get("bio"):
350348
result["description"] = result.get("bio", "")
351349
elif "description" not in result or not result.get("description"):
352350
result["description"] = ""
353-
# Ensure status field exists (publishers don't have traditional status)
354351
if "status" not in result:
355352
result["status"] = "active"
353+
if "tags" not in result:
354+
result["tags"] = []
355+
if "sectors" not in result or result.get("sectors") is None:
356+
result["sectors"] = []
357+
if "geographies" not in result:
358+
result["geographies"] = []
356359
else: # dataset
357360
if "title" not in result:
358361
result["title"] = ""
@@ -409,7 +412,6 @@ def perform_unified_search(
409412
if hasattr(response, "aggregations"):
410413
aggs_dict = response.aggregations.to_dict()
411414

412-
# Process types aggregation
413415
if "types" in aggs_dict:
414416
aggregations["types"] = {}
415417
for bucket in aggs_dict["types"]["buckets"]:
@@ -428,7 +430,6 @@ def perform_unified_search(
428430
aggregations["types"]["publisher"] = 0
429431
aggregations["types"]["publisher"] += bucket["doc_count"]
430432

431-
# Process other aggregations
432433
for agg_name in ["tags", "sectors", "geographies", "status"]:
433434
if agg_name in aggs_dict:
434435
aggregations[agg_name] = {}
@@ -450,10 +451,8 @@ def get(self, request: Any) -> Response:
450451
"types", "dataset,usecase,aimodel,collaborative,publisher"
451452
) # Which entity types to search
452453

453-
# Parse entity types
454454
types_list = [t.strip() for t in entity_types.split(",")]
455455

456-
# Handle filters
457456
filters: Dict[str, str] = {}
458457
for key, values in request.GET.lists():
459458
if key not in ["query", "page", "size", "types"]:

0 commit comments

Comments
 (0)