Skip to content

Commit ac37545

Browse files
docs #38; updated
1 parent f524141 commit ac37545

File tree

4 files changed

+66
-3
lines changed

4 files changed

+66
-3
lines changed

advanced_usage_examples.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ Sample view
441441
# Define search fields
442442
search_fields = (
443443
'title',
444-
'description',
445444
'summary',
445+
'description',
446446
)
447447
# Define filtering fields
448448
filter_fields = {
@@ -542,6 +542,32 @@ fields add multiple ``search`` query params and field names separated with
542542
543543
http://127.0.0.1:8080/search/books/?search=title|education&search=summary|technology
544544
545+
**Search with boosting**
546+
547+
It's possible to boost search fields. In order to do that change the
548+
`search_fields` definition of the `BookDocumentViewSet` as follows:
549+
550+
.. code-block:: python
551+
552+
class BookDocumentView(BaseDocumentViewSet):
553+
"""The BookDocument view."""
554+
555+
# ...
556+
557+
# Define search fields
558+
search_fields = {
559+
'title': {'boost': 4},
560+
'summary': {'boost': 2},
561+
'description': None,
562+
}
563+
564+
# Order by `_score` first.
565+
ordering = ('_score', 'id', 'title', 'price',)
566+
567+
# ...
568+
569+
Note, that we are ordering results by `_score` first.
570+
545571
Filtering
546572
~~~~~~~~~
547573

docs/advanced_usage_examples.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ Sample view
441441
# Define search fields
442442
search_fields = (
443443
'title',
444-
'description',
445444
'summary',
445+
'description',
446446
)
447447
# Define filtering fields
448448
filter_fields = {
@@ -542,6 +542,32 @@ fields add multiple ``search`` query params and field names separated with
542542
543543
http://127.0.0.1:8080/search/books/?search=title|education&search=summary|technology
544544
545+
**Search with boosting**
546+
547+
It's possible to boost search fields. In order to do that change the
548+
`search_fields` definition of the `BookDocumentViewSet` as follows:
549+
550+
.. code-block:: python
551+
552+
class BookDocumentView(BaseDocumentViewSet):
553+
"""The BookDocument view."""
554+
555+
# ...
556+
557+
# Define search fields
558+
search_fields = {
559+
'title': {'boost': 4},
560+
'summary': {'boost': 2},
561+
'description': None,
562+
}
563+
564+
# Order by `_score` first.
565+
ordering = ('_score', 'id', 'title', 'price',)
566+
567+
# ...
568+
569+
Note, that we are ordering results by `_score` first.
570+
545571
Filtering
546572
~~~~~~~~~
547573

docs/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ are used for versioning (schema follows below):
1515
0.3.4 to 0.4).
1616
- All backwards incompatible changes are mentioned in this document.
1717

18+
0.7.1
19+
-----
20+
2018-04-04
21+
22+
.. note::
23+
24+
Release supported by `Goldmund, Wyldebeast & Wunderliebe
25+
<https://goldmund-wyldebeast-wunderliebe.nl/>`_
26+
27+
- Add query `boost` support for search fields.
28+
1829
0.7
1930
---
2031
2018-03-08

src/django_elasticsearch_dsl_drf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
__title__ = 'django-elasticsearch-dsl-drf'
6-
__version__ = '0.7'
6+
__version__ = '0.7.1'
77
__author__ = 'Artur Barseghyan <[email protected]>'
88
__copyright__ = '2017-2018 Artur Barseghyan'
99
__license__ = 'GPL 2.0/LGPL 2.1'

0 commit comments

Comments
 (0)