Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1462475: Remove zones from boosting
Browse files Browse the repository at this point in the history
"boost" was 8.0 for zones, which is used in the SearchFilterBackend to
boost zone root results. In the future, the boost function could be
simplified.
  • Loading branch information
jwhitlock committed Aug 6, 2018
1 parent e4fada3 commit 07ea9cc
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions kuma/wiki/search.py
Expand Up @@ -7,7 +7,6 @@

from celery import chain
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -70,8 +69,10 @@ def case_insensitive_keywords(cls, keywords):

@classmethod
def from_django(cls, obj):
is_root_document = (obj.slug.count('/') == 1)
doc = {
'id': obj.id,
'boost': 4.0 if is_root_document else 1.0,
'title': obj.title,
'slug': obj.slug,
'summary': obj.get_summary_text(),
Expand All @@ -87,20 +88,6 @@ def from_django(cls, obj):
obj.extract.html_attributes()),
}

# Check if the document has a document zone attached
try:
is_zone = bool(obj.zone)
except ObjectDoesNotExist:
is_zone = False

if is_zone:
# boost all documents that are a zone
doc['boost'] = 8.0
elif obj.slug.count('/') == 1:
# a little boost if no zone but still first level
doc['boost'] = 4.0
else:
doc['boost'] = 1.0
if obj.parent:
doc['parent'] = {
'id': obj.parent.id,
Expand Down

0 comments on commit 07ea9cc

Please sign in to comment.