django_elasticsearch_dsl_drf package¶
Subpackages¶
- django_elasticsearch_dsl_drf.fields package
- django_elasticsearch_dsl_drf.filter_backends package
- Subpackages
- django_elasticsearch_dsl_drf.filter_backends.aggregations package
- django_elasticsearch_dsl_drf.filter_backends.filtering package
- Submodules
- django_elasticsearch_dsl_drf.filter_backends.filtering.common module
- django_elasticsearch_dsl_drf.filter_backends.filtering.geo_spatial module
- django_elasticsearch_dsl_drf.filter_backends.filtering.ids module
- django_elasticsearch_dsl_drf.filter_backends.filtering.nested module
- django_elasticsearch_dsl_drf.filter_backends.filtering.post_filter module
- Module contents
- django_elasticsearch_dsl_drf.filter_backends.ordering package
- django_elasticsearch_dsl_drf.filter_backends.search package
- Subpackages
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends package
- Submodules
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.base module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.match module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.match_phrase module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.match_phrase_prefix module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.multi_match module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.nested module
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends.simple_query_string module
- Module contents
- django_elasticsearch_dsl_drf.filter_backends.search.query_backends package
- Submodules
- django_elasticsearch_dsl_drf.filter_backends.search.base module
- django_elasticsearch_dsl_drf.filter_backends.search.compound module
- django_elasticsearch_dsl_drf.filter_backends.search.historical module
- django_elasticsearch_dsl_drf.filter_backends.search.multi_match module
- django_elasticsearch_dsl_drf.filter_backends.search.query_string module
- django_elasticsearch_dsl_drf.filter_backends.search.simple_query_string module
- Module contents
- Subpackages
- django_elasticsearch_dsl_drf.filter_backends.suggester package
- Submodules
- django_elasticsearch_dsl_drf.filter_backends.faceted_search module
- django_elasticsearch_dsl_drf.filter_backends.highlight module
- django_elasticsearch_dsl_drf.filter_backends.mixins module
- django_elasticsearch_dsl_drf.filter_backends.source module
- Module contents
- Subpackages
- django_elasticsearch_dsl_drf.management package
- django_elasticsearch_dsl_drf.tests package
- Submodules
- django_elasticsearch_dsl_drf.tests.base module
- django_elasticsearch_dsl_drf.tests.data_mixins module
- django_elasticsearch_dsl_drf.tests.test_faceted_search module
- django_elasticsearch_dsl_drf.tests.test_filtering_common module
- django_elasticsearch_dsl_drf.tests.test_filtering_geo_spatial module
- django_elasticsearch_dsl_drf.tests.test_filtering_global_aggregations module
- django_elasticsearch_dsl_drf.tests.test_filtering_nested module
- django_elasticsearch_dsl_drf.tests.test_filtering_post_filter module
- django_elasticsearch_dsl_drf.tests.test_functional_suggesters module
- django_elasticsearch_dsl_drf.tests.test_helpers module
- django_elasticsearch_dsl_drf.tests.test_highlight module
- django_elasticsearch_dsl_drf.tests.test_more_like_this module
- django_elasticsearch_dsl_drf.tests.test_ordering_common module
- django_elasticsearch_dsl_drf.tests.test_ordering_geo_spatial module
- django_elasticsearch_dsl_drf.tests.test_pagination module
- django_elasticsearch_dsl_drf.tests.test_pip_helpers module
- django_elasticsearch_dsl_drf.tests.test_query_friendly_pagination module
- django_elasticsearch_dsl_drf.tests.test_search module
- django_elasticsearch_dsl_drf.tests.test_search_multi_match module
- django_elasticsearch_dsl_drf.tests.test_search_simple_query_string module
- django_elasticsearch_dsl_drf.tests.test_serializers module
- django_elasticsearch_dsl_drf.tests.test_source module
- django_elasticsearch_dsl_drf.tests.test_suggesters module
- django_elasticsearch_dsl_drf.tests.test_versions module
- django_elasticsearch_dsl_drf.tests.test_views module
- django_elasticsearch_dsl_drf.tests.test_wrappers module
- Module contents
Submodules¶
django_elasticsearch_dsl_drf.analyzers module¶
Analyzers.
django_elasticsearch_dsl_drf.apps module¶
Apps.
django_elasticsearch_dsl_drf.compat module¶
Transitional compatibility module. Contains various field wrappers and helpers for painless (testing of) Elastic 2.x to Elastic 5.x transition. This module is not supposed to solve all transition issues for you. Better move to Elastic 5.x as soon as possible.
- class django_elasticsearch_dsl_drf.compat.KeywordField(attr=None, **kwargs)[source]¶
Bases:
django_elasticsearch_dsl.fields.DEDField
,elasticsearch_dsl.field.Keyword
- django_elasticsearch_dsl_drf.compat.StringField(**kwargs)¶
String field.
- Parameters
kwargs –
- Returns
django_elasticsearch_dsl_drf.constants module¶
Constants module. Contains Elasticsearch constants, lookup constants, functional constants, suggesters, etc.
django_elasticsearch_dsl_drf.elasticsearch_helpers module¶
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.Document.
- 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, query=None)[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) –
query (elasticsearch_dsl.query.Q) – Q query
- 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
,django_elasticsearch_dsl_drf.pagination.GetCountMixin
A limit/offset pagination.
Example:
- class django_elasticsearch_dsl_drf.pagination.Page(object_list, number, paginator, facets)[source]¶
Bases:
django.core.paginator.Page
,django_elasticsearch_dsl_drf.pagination.GetCountMixin
Page for Elasticsearch.
- class django_elasticsearch_dsl_drf.pagination.PageNumberPagination(*args, **kwargs)[source]¶
Bases:
rest_framework.pagination.PageNumberPagination
,django_elasticsearch_dsl_drf.pagination.GetCountMixin
Page number pagination.
A simple page number based style that supports page numbers as query parameters.
Example:
- django_paginator_class¶
- class django_elasticsearch_dsl_drf.pagination.Paginator(object_list, per_page, orphans=0, allow_empty_first_page=True)[source]¶
Bases:
django.core.paginator.Paginator
Paginator for Elasticsearch.
- class django_elasticsearch_dsl_drf.pagination.QueryFriendlyPageNumberPagination(*args, **kwargs)[source]¶
Bases:
django_elasticsearch_dsl_drf.pagination.PageNumberPagination
Page number pagination.
A simple page number based style that supports page numbers as query parameters.
Example:
- django_paginator_class¶
alias of
django_elasticsearch_dsl_drf.pagination.QueryFriendlyPaginator
- orphans_query_param = 'orphans'¶
- page_size_query_param = 'page_size'¶
- class django_elasticsearch_dsl_drf.pagination.QueryFriendlyPaginator(object_list, per_page, orphans=0, allow_empty_first_page=True)[source]¶
Bases:
django_elasticsearch_dsl_drf.pagination.Paginator
,django_elasticsearch_dsl_drf.pagination.GetCountMixin
Paginator for Elasticsearch.
django_elasticsearch_dsl_drf.pip_helpers module¶
Pip helpers module.
django_elasticsearch_dsl_drf.serializers module¶
Serializers.
- class django_elasticsearch_dsl_drf.serializers.DocumentSerializer(*args, **kwargs)[source]¶
Bases:
rest_framework.serializers.Serializer
A dynamic DocumentSerializer class.
- class django_elasticsearch_dsl_drf.serializers.DocumentSerializerMeta(name, bases, attrs)[source]¶
Bases:
rest_framework.serializers.SerializerMetaclass
Metaclass for the DocumentSerializer.
Ensures that all declared subclasses implemented a Meta.
- class django_elasticsearch_dsl_drf.serializers.Meta(name, bases, attrs)[source]¶
Bases:
type
Template for the DocumentSerializerMeta.Meta class.
- exclude = ()¶
- field_aliases = {}¶
- field_options = {}¶
- fields = ()¶
- ignore_fields = ()¶
- index_aliases = {}¶
- index_classes = ()¶
- search_fields = ()¶
- serializers = ()¶
django_elasticsearch_dsl_drf.utils module¶
Utils.
django_elasticsearch_dsl_drf.versions module¶
Contains information about the current Elasticsearch version in use, including (LTE and GTE).
django_elasticsearch_dsl_drf.viewsets module¶
Base ViewSets.
- class django_elasticsearch_dsl_drf.viewsets.BaseDocumentViewSet(*args, **kwargs)[source]¶
Bases:
rest_framework.viewsets.ReadOnlyModelViewSet
Base document ViewSet.
- dictionary_proxy¶
- document = None¶
- document_uid_field = 'id'¶
- ignore = []¶
- pagination_class¶
alias of
django_elasticsearch_dsl_drf.pagination.PageNumberPagination
- class django_elasticsearch_dsl_drf.viewsets.DocumentViewSet(*args, **kwargs)[source]¶
Bases:
django_elasticsearch_dsl_drf.viewsets.BaseDocumentViewSet
,django_elasticsearch_dsl_drf.viewsets.SuggestMixin
,django_elasticsearch_dsl_drf.viewsets.FunctionalSuggestMixin
DocumentViewSet with suggest and functional-suggest mix-ins.
- class django_elasticsearch_dsl_drf.viewsets.FunctionalSuggestMixin[source]¶
Bases:
object
Functional suggest mixin.
django_elasticsearch_dsl_drf.wrappers module¶
- class django_elasticsearch_dsl_drf.wrappers.Wrapper[source]¶
Bases:
object
Wrapper.
Example: >>> from django_elasticsearch_dsl_drf.wrappers import dict_to_obj >>> >>> mapping = { >>> ‘country’: { >>> ‘name’: ‘Netherlands’, >>> ‘province’: { >>> ‘name’: ‘North Holland’, >>> ‘city’: { >>> ‘name’: ‘Amsterdam’, >>> } >>> } >>> } >>> } >>> >>> wrapper = dict_to_obj(mapping) >>> wrapper.country.name >>> “Netherlands” >>> wrapper.country.province.name >>> “North Holland” >>> wrapper.country.province.city.name >>> “Amsterdam” >>> wrapper.as_dict >>> { >>> ‘country’: { >>> ‘name’: ‘Netherlands’, >>> ‘province’: { >>> ‘name’: ‘North Holland’, >>> ‘city’: { >>> ‘name’: ‘Amsterdam’, >>> } >>> } >>> } >>> } >>> str(wrapper) >>> “Netherlands”
- property as_dict¶
As dict.
- Returns
- Return type
dict
- property as_json¶
As JSON.
- Returns
- Return type
str
- django_elasticsearch_dsl_drf.wrappers.dict_to_obj(mapping)[source]¶
dict to obj mapping.
- Parameters
mapping (dict) –
- Returns
- Return type
- django_elasticsearch_dsl_drf.wrappers.obj_to_dict(obj)[source]¶
Wrapper to dict.
- Parameters
obj (`obj`:Wrapper:) –
- Returns
- Return type
dict
Module contents¶
Integrate Elasticsearch DSL with Django REST framework.