Commit 484f29e59c2a6111685a446e352287bee9e38b08
1 parent
d70cc0d4
Exists in
master
and in
39 other branches
Using thread score to help in thread relevance
Showing
3 changed files
with
17 additions
and
10 deletions
Show diff stats
src/proxy/search_indexes.py
... | ... | @@ -143,11 +143,9 @@ class RevisionIndex(BaseIndex, indexes.Indexable): |
143 | 143 | def get_updated_field(self): |
144 | 144 | return 'created' |
145 | 145 | |
146 | - def get_boost(self, obj, data): | |
147 | - if obj.hits <= 10: | |
148 | - data['boost'] = 0.8 | |
149 | - else: | |
150 | - data['boost'] = math.log(obj.hits) * 0.8 | |
146 | + def get_boost(self, obj): | |
147 | + boost = super(RevisionIndex, self).get_boost(obj) | |
148 | + return boost * 0.8 | |
151 | 149 | |
152 | 150 | def prepare_icon_name(self, obj): |
153 | 151 | return u'align-right' | ... | ... |
src/search/base_indexes.py
... | ... | @@ -22,15 +22,15 @@ class BaseIndex(indexes.SearchIndex): |
22 | 22 | def get_updated_field(self): |
23 | 23 | return 'modified' |
24 | 24 | |
25 | - def get_boost(self, obj, data): | |
25 | + def get_boost(self, obj): | |
26 | 26 | if obj.hits <= 10: |
27 | - data['boost'] = 1 | |
28 | - else: | |
29 | - data['boost'] = math.log(obj.hits) | |
27 | + return 1 | |
28 | + | |
29 | + return math.log(obj.hits) | |
30 | 30 | |
31 | 31 | def prepare(self, obj): |
32 | 32 | data = super(BaseIndex, self).prepare(obj) |
33 | - self.get_boost(obj, data) | |
33 | + data['boost'] = self.get_boost(obj) | |
34 | 34 | return data |
35 | 35 | |
36 | 36 | def prepare_author(self, obj): | ... | ... |
src/super_archives/search_indexes.py
... | ... | @@ -25,6 +25,7 @@ class ThreadIndex(BaseIndex, indexes.Indexable): |
25 | 25 | model_attr='mailinglist__get_absolute_url', |
26 | 26 | indexed=False, |
27 | 27 | ) |
28 | + score = indexes.IntegerField(model_attr='score') | |
28 | 29 | |
29 | 30 | def get_model(self): |
30 | 31 | return Thread |
... | ... | @@ -64,3 +65,11 @@ class ThreadIndex(BaseIndex, indexes.Indexable): |
64 | 65 | return self.get_model().objects.filter( |
65 | 66 | spam=False |
66 | 67 | ).exclude(subject_token='') |
68 | + | |
69 | + def get_boost(self, obj): | |
70 | + boost = super(ThreadIndex, self).get_boost(obj) | |
71 | + | |
72 | + if obj.score >= 20: | |
73 | + boost = boost * math.log(obj.score, 20) | |
74 | + | |
75 | + return boost | ... | ... |