feat: title weight procedure
All checks were successful
Deploy on push / deploy (push) Successful in 1m16s

This commit is contained in:
Stepan Vladovskiy 2025-04-15 19:32:34 -03:00
parent e382cc1ea5
commit 27b0928e73

View File

@ -254,14 +254,18 @@ class SearchService:
return
try:
# Repeat title 3 times for higher keyword relevance
title_repeat = ". ".join(filter(None, [shout.title] * 3))
# Combine all text fields
text = " ".join(filter(None, [
shout.title or "",
text_parts = [
title_repeat,
shout.subtitle or "",
shout.lead or "",
shout.body or "",
shout.media or ""
]))
]
text = " ".join(filter(None, text_parts))
if not text.strip():
logger.warning(f"No text content to index for shout {shout.id}")
@ -305,7 +309,12 @@ class SearchService:
for shout in shouts:
try:
text_fields = []
for field_name in ['title', 'subtitle', 'lead', 'body']:
# Repeat title 3 times
title_repeat = ". ".join(filter(None, [getattr(shout, "title", None)] * 3))
text_fields = [title_repeat]
for field_name in ['subtitle', 'lead', 'body']:
field_value = getattr(shout, field_name, None)
if field_value and isinstance(field_value, str) and field_value.strip():
text_fields.append(field_value.strip())