django_elasticsearch_dsl_drf package¶
Subpackages¶
- django_elasticsearch_dsl_drf.filter_backends package
- django_elasticsearch_dsl_drf.tests package
- Submodules
- django_elasticsearch_dsl_drf.tests.base module
- django_elasticsearch_dsl_drf.tests.test_faceted_search module
- django_elasticsearch_dsl_drf.tests.test_filtering module
- django_elasticsearch_dsl_drf.tests.test_helpers module
- django_elasticsearch_dsl_drf.tests.test_ordering module
- django_elasticsearch_dsl_drf.tests.test_pagination module
- django_elasticsearch_dsl_drf.tests.test_search module
- django_elasticsearch_dsl_drf.tests.test_views module
- Module contents
Submodules¶
django_elasticsearch_dsl_drf.apps module¶
Apps.
django_elasticsearch_dsl_drf.constants module¶
Constants module. Contains Elasticsearch constants, lookup constants, functional constants, etc.
django_elasticsearch_dsl_drf.helpers module¶
Helpers.
-
django_elasticsearch_dsl_drf.helpers.
get_document_for_model
(model)[source]¶ Get document for model given.
Parameters: model (Subclass of django.db.models.Model.) – Model to get document index for. Returns: Document index for the given model. Return type: Subclass of django_elasticsearch_dsl.DocType.
-
django_elasticsearch_dsl_drf.helpers.
get_index_and_mapping_for_model
(model)[source]¶ Get index and mapping for model.
Parameters: model (Subclass of django.db.models.Model.) – Django model for which to get index and mapping for. Returns: Index and mapping values. Return type: tuple.
-
django_elasticsearch_dsl_drf.helpers.
more_like_this
(obj, fields, max_query_terms=25, min_term_freq=2, min_doc_freq=5, max_doc_freq=0)[source]¶ More like this.
https://www.elastic.co/guide/en/elasticsearch/reference/current/ query-dsl-mlt-query.html
Parameters: - obj (Instance of django.db.models.Model (sub-classed) model.) – Django model instance for which similar objects shall be found.
- fields (list) – Fields to search in.
- max_query_terms (int) –
- min_term_freq (int) –
- min_doc_freq (int) –
- max_doc_freq (int) –
Returns: List of objects.
Return type: elasticsearch_dsl.search.Search
Example:
>>> from django_elasticsearch_dsl_drf.helpers import more_like_this >>> from books.models import Book >>> book = Book.objects.first() >>> similar_books = more_like_this( >>> book, >>> ['title', 'description', 'summary'] >>> )
-
django_elasticsearch_dsl_drf.helpers.
sort_by_list
(unsorted_dict, sorted_keys)[source]¶ Sort an OrderedDict by list of sorted keys.
Parameters: - unsorted_dict (collections.OrderedDict) – Source dictionary.
- sorted_keys (list) – Keys to sort on.
Returns: Sorted dictionary.
Return type: collections.OrderedDict
django_elasticsearch_dsl_drf.pagination module¶
Pagination.
-
class
django_elasticsearch_dsl_drf.pagination.
LimitOffsetPagination
(*args, **kwargs)[source]¶ Bases:
rest_framework.pagination.LimitOffsetPagination
A limit/offset pagination.
Example:
-
class
django_elasticsearch_dsl_drf.pagination.
Page
(object_list, number, paginator, facets)[source]¶ Bases:
django.core.paginator.Page
Page for Elasticsearch.
-
class
django_elasticsearch_dsl_drf.pagination.
PageNumberPagination
(*args, **kwargs)[source]¶ Bases:
rest_framework.pagination.PageNumberPagination
Page number pagination.
A simple page number based style that supports page numbers as query parameters.
Example:
django_elasticsearch_dsl_drf.serializers module¶
Serializers.
-
class
django_elasticsearch_dsl_drf.serializers.
DocumentSerializer
(instance=None, data=<class rest_framework.fields.empty>, **kwargs)[source]¶ Bases:
rest_framework.serializers.Serializer
A dynamic DocumentSerializer class.
django_elasticsearch_dsl_drf.utils module¶
Utils.
django_elasticsearch_dsl_drf.views module¶
django_elasticsearch_dsl_drf.viewsets module¶
Base ViewSets.
Module contents¶
Integrate Elasticsearch DSL with Django REST framework.