Skip to content

Commit 59636c4

Browse files
Return 0 instead of None for EmptySearch
1 parent d1ba77e commit 59636c4

File tree

14 files changed

+72
-13
lines changed

14 files changed

+72
-13
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ services:
77
build:
88
context: .
99
dockerfile: ./docker/elasticsearch/Dockerfile
10-
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.2
1110
volumes:
1211
- esdata:/usr/share/elasticsearch/data
1312
ports:

docker/backend/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM docker.io/python:3.6.7-slim-jessie
1+
FROM docker.io/python:3.9-slim-bullseye
22
ENV PYTHONUNBUFFERED 1
33

44
RUN apt-get update
55
RUN apt-get install -y build-essential
66
RUN apt-get install -y cmake
77
RUN apt-get install -y libpq-dev
8-
RUN apt-get install -y python-dev
9-
RUN apt-get install -y python-pip
10-
RUN apt-get install -y python-imaging
8+
#RUN apt-get install -y python-dev
9+
#RUN apt-get install -y python-pip
10+
#RUN apt-get install -y python-imaging
1111
RUN apt-get install -y mc
1212
RUN apt-get install -y nano
1313

examples/requirements/debug.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ simplegeneric==0.8.1
3636
# via ipython
3737
six==1.16.0
3838
# via prompt-toolkit
39-
traitlets==5.0.5
39+
traitlets==4.3
4040
# via ipython
4141
wcwidth==0.2.5
4242
# via prompt-toolkit

examples/requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ sqlparse==0.4.1
162162
# django-debug-toolbar
163163
toml==0.10.2
164164
# via pylint
165-
traitlets==5.0.5
165+
traitlets==4.3
166166
# via ipython
167167
urllib3==1.26.6
168168
# via requests
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.9
3+
# To update, run:
4+
#
5+
# pip-compile elastic_docker.in
6+
#
7+
django-elasticsearch-dsl==7.1.1
8+
# via -r elastic_docker.in
9+
elasticsearch==7.5.1
10+
# via
11+
# -r elastic_docker.in
12+
# elasticsearch-dsl
13+
elasticsearch-dsl==7.1.0
14+
# via
15+
# -r elastic_docker.in
16+
# django-elasticsearch-dsl
17+
python-dateutil==2.8.2
18+
# via elasticsearch-dsl
19+
six==1.16.0
20+
# via
21+
# django-elasticsearch-dsl
22+
# elasticsearch-dsl
23+
# python-dateutil
24+
urllib3==1.26.9
25+
# via elasticsearch

examples/simple/factories/books_galaxy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from factory import DjangoModelFactory, SubFactory
1+
from factory import SubFactory
2+
from factory.django import DjangoModelFactory
23

34
from books.models import Galaxy
45

examples/simple/factories/books_planet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from factory import DjangoModelFactory, SubFactory
1+
from factory import SubFactory
2+
from factory.django import DjangoModelFactory
23

34
from books.models import Planet
45

examples/simple/search_indexes/urls.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
BookMoreLikeThisNoOptionsDocumentViewSet,
1717
BookMultiMatchOptionsPhasePrefixSearchFilterBackendDocumentViewSet,
1818
BookMultiMatchSearchFilterBackendDocumentViewSet,
19+
BookNoRecordsDocumentViewSet,
1920
BookOrderingByScoreCompoundSearchBackendDocumentViewSet,
2021
BookOrderingByScoreDocumentViewSet,
2122
BookPermissionsDocumentViewSet,
@@ -80,7 +81,11 @@
8081
BookDocumentViewSet,
8182
basename='bookdocument'
8283
)
83-
84+
router.register(
85+
r'books-no-records',
86+
BookNoRecordsDocumentViewSet,
87+
basename='bookdocument-no-records'
88+
)
8489
router.register(
8590
r'books-query-friendly-pagination',
8691
QueryFriendlyPaginationBookDocumentViewSet,

examples/simple/search_indexes/viewsets/book/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .more_like_this import *
1111
from .multi_match import *
1212
from .multi_match_options_phrase_prefix import *
13+
from .no_records import *
1314
from .ordering_by_score import *
1415
from .ordering_by_score_compound_search import *
1516
from .permissions import *
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django_elasticsearch_dsl_drf.utils import EmptySearch
2+
3+
from .default import BookDocumentViewSet
4+
5+
__all__ = (
6+
'BookNoRecordsDocumentViewSet',
7+
)
8+
9+
10+
class BookNoRecordsDocumentViewSet(BookDocumentViewSet):
11+
"""Book document view set based on compound search backend."""
12+
13+
def get_queryset(self):
14+
queryset = EmptySearch()
15+
queryset.model = self.document.Django.model
16+
return queryset

0 commit comments

Comments
 (0)