Skip to content

Commit bdc9358

Browse files
#38; more on tests
1 parent e2f77d4 commit bdc9358

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

examples/simple/search_indexes/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
AddressDocumentViewSet,
66
AuthorDocumentViewSet,
77
BookDocumentViewSet,
8+
BookOrderingByScoreDocumentViewSet,
89
CityDocumentViewSet,
910
PublisherDocumentViewSet,
1011
)
@@ -31,6 +32,12 @@
3132
base_name='bookdocument'
3233
)
3334

35+
books = router.register(
36+
r'books-ordered-by-score',
37+
BookOrderingByScoreDocumentViewSet,
38+
base_name='bookdocument_ordered_by_score'
39+
)
40+
3441
cities = router.register(
3542
r'cities',
3643
CityDocumentViewSet,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from .address import AddressDocumentViewSet
22
from .author import AuthorDocumentViewSet
3-
from .book import BookDocumentViewSet
3+
from .book import BookDocumentViewSet, BookOrderingByScoreDocumentViewSet
44
from .city import CityDocumentViewSet
55
from .publisher import PublisherDocumentViewSet
66

77
__all__ = (
88
'AddressDocumentViewSet',
99
'AuthorDocumentViewSet',
1010
'BookDocumentViewSet',
11+
'BookOrderingByScoreDocumentViewSet',
1112
'CityDocumentViewSet',
1213
'PublisherDocumentViewSet',
1314
)

examples/simple/search_indexes/viewsets/book.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
__all__ = (
3232
'BookDocumentViewSet',
33+
'BookOrderingByScoreDocumentViewSet',
3334
)
3435

3536

@@ -205,3 +206,9 @@ class BookDocumentViewSet(BaseDocumentViewSet):
205206
'tag_suggest': 'tags.suggest',
206207
'summary_suggest': 'summary',
207208
}
209+
210+
211+
class BookOrderingByScoreDocumentViewSet(BookDocumentViewSet):
212+
"""Same as BookDocumentViewSet, but sorted by _score."""
213+
214+
ordering = ('_score', 'id', 'title', 'price',)

src/django_elasticsearch_dsl_drf/tests/test_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _search_boost(self, search_term, ordering):
146146
"""
147147
self.authenticate()
148148

149-
url = reverse('bookdocument-list', kwargs={})
149+
url = reverse('bookdocument_ordered_by_score-list', kwargs={})
150150
data = {}
151151

152152
filtered_response = self.client.get(

0 commit comments

Comments
 (0)