Index tags and boost subtitle

This commit is contained in:
Jake Howard 2022-10-31 20:58:02 +00:00
parent 1e2e488516
commit 66465dafe8
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -5,6 +5,7 @@ from django.utils import timezone
from django.utils.functional import cached_property from django.utils.functional import cached_property
from modelcluster.fields import ParentalManyToManyField from modelcluster.fields import ParentalManyToManyField
from wagtail.admin.panels import FieldPanel from wagtail.admin.panels import FieldPanel
from wagtail.search import index
from wagtailautocomplete.edit_handlers import AutocompletePanel from wagtailautocomplete.edit_handlers import AutocompletePanel
from website.common.models import BaseContentPage, BaseListingPage from website.common.models import BaseContentPage, BaseListingPage
@ -57,6 +58,10 @@ class BlogPostPage(BaseContentPage):
AutocompletePanel("tags"), AutocompletePanel("tags"),
] ]
search_fields = BaseContentPage.search_fields + [
index.RelatedFields("tags", [index.SearchField("title", boost=1)])
]
@cached_property @cached_property
def tag_list_page_url(self) -> Optional[str]: def tag_list_page_url(self) -> Optional[str]:
return SingletonPageCache.get_url(BlogPostTagListPage) return SingletonPageCache.get_url(BlogPostTagListPage)