kopia lustrzana https://github.com/wagtail/wagtail
Fix annotate_score followed by slice (#3518)
This fixes the bug reported by @nimasmi in https://github.com/wagtail/wagtail/issues/3431#issuecomment-288051751 Slicing creates a new SearchResults object but the ``score_field`` (set by ``.annotate_score()`` wasn't being passed along to the new SearchResults causing the score to not be annotated.pull/3057/merge
rodzic
cc52c1b1ca
commit
babe8a0c09
|
|
@ -48,6 +48,7 @@ Changelog
|
|||
* Fix: The page type usage listing now have a translatable page title (Ramon de Jezus)
|
||||
* Fix: Styles for submission filtering form now have a consistent height. (Thijs Kramer)
|
||||
* Fix: Custom user models with a primary key type requiring `get_db_prep_value` conversion are now supported (thenewguy)
|
||||
* Fix: Slicing a search result set no longer loses the annotation added by `annotate_score` (Karl Hobley)
|
||||
|
||||
|
||||
1.9 (16.02.2017)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ Bug fixes
|
|||
* List-based fields within form builder form submissions are now displayed as comma-separated strings rather than as Python lists (Christine Ho, Matt Westcott)
|
||||
* The page type usage listing now have a translatable page title (Ramon de Jezus)
|
||||
* Styles for submission filtering form now have a consistent height. (Thijs Kramer)
|
||||
* Slicing a search result set no longer loses the annotation added by `annotate_score` (Karl Hobley)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ class BaseSearchResults(object):
|
|||
new = klass(self.backend, self.query, prefetch_related=self.prefetch_related)
|
||||
new.start = self.start
|
||||
new.stop = self.stop
|
||||
new._score_field = self._score_field
|
||||
return new
|
||||
|
||||
def _do_search(self):
|
||||
|
|
|
|||
|
|
@ -254,6 +254,13 @@ class TestElasticsearchSearchBackend(BackendTests, TestCase):
|
|||
for result in results:
|
||||
self.assertIsInstance(result._score, float)
|
||||
|
||||
def test_annotate_score_with_slice(self):
|
||||
# #3431 - Annotate score wasn't being passed to new queryset when slicing
|
||||
results = self.backend.search("Hello", models.SearchTest).annotate_score('_score')[:10]
|
||||
|
||||
for result in results:
|
||||
self.assertIsInstance(result._score, float)
|
||||
|
||||
|
||||
class TestElasticsearchSearchQuery(TestCase):
|
||||
def assertDictEqual(self, a, b):
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue