Skip to content

Commit

Permalink
prepare 0.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Sep 20, 2017
1 parent 7d32175 commit c33d106
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.


0.3.10
------
2017-09-20

- Minor fixes.
- Simplified Elasticsearch version check.

0.3.9
-----
2017-09-12
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.


0.3.10
------
2017-09-20

- Minor fixes.
- Simplified Elasticsearch version check.

0.3.9
-----
2017-09-12
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import find_packages, setup

version = '0.3.9'
version = '0.3.10'

DOCS_TRANSFORMATIONS = (
(
Expand Down
2 changes: 1 addition & 1 deletion src/django_elasticsearch_dsl_drf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

__title__ = 'django-elasticsearch-dsl-drf'
__version__ = '0.3.9'
__version__ = '0.3.10'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2017 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
Expand Down
19 changes: 3 additions & 16 deletions src/django_elasticsearch_dsl_drf/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
module is not supposed to solve all transition issues for you. Better move to
Elastic 5.x as soon as possible.
"""
from urllib3.exceptions import NewConnectionError

from django_elasticsearch_dsl import fields

from elasticsearch import Elasticsearch
from elasticsearch.exceptions import ConnectionError


__title__ = 'django_elasticsearch_dsl_drf.compat'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2017 Artur Barseghyan'
Expand All @@ -33,17 +28,9 @@ def get_elasticsearch_version(default=(2, 0, 0)):
:rtype: list
"""
try:
es = Elasticsearch()
version = es.info()['version']['number']
return [int(__v) for __v in version.split('.', 2)]
except (Exception,
ConnectionError,
NewConnectionError,
NameError,
AttributeError,
ValueError,
TypeError,
OSError):
from elasticsearch_dsl import __version__
return __version__
except ImportError:
return default


Expand Down
19 changes: 15 additions & 4 deletions src/django_elasticsearch_dsl_drf/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ def more_like_this(obj,
_client = connections.get_connection()
_search = Search(using=_client, index=_index)

kwargs = {}

if max_query_terms is not None:
kwargs['max_query_terms'] = max_query_terms

if min_term_freq is not None:
kwargs['min_term_freq'] = min_term_freq

if min_doc_freq is not None:
kwargs['min_doc_freq'] = min_doc_freq

if max_doc_freq is not None:
kwargs['max_doc_freq'] = max_doc_freq

return _search.query(
MoreLikeThis(
fields=fields,
Expand All @@ -133,9 +147,6 @@ def more_like_this(obj,
'_index': "{}".format(_index),
'_type': "{}".format(_mapping)
},
max_query_terms=max_query_terms,
min_term_freq=min_term_freq,
min_doc_freq=min_doc_freq,
max_doc_freq=max_doc_freq,
**kwargs
)
)

0 comments on commit c33d106

Please sign in to comment.