graphene_elastic.filter_backends package

Submodules

graphene_elastic.filter_backends.base module

class graphene_elastic.filter_backends.base.BaseBackend(connection_field, args=None)[source]

Bases: object

Base backend.

alter_connection(connection, slice)[source]

Alter connection object.

You can add various properties here, returning the altered object. Typical use-case would be adding facets to the connection.

Parameters:
  • connection
  • slice
Returns:

classmethod apply_filter(queryset, options=None, args=None, kwargs=None)[source]

Apply filter.

Parameters:
  • queryset
  • options
  • args
  • kwargs
Returns:

classmethod apply_query(queryset, options=None, args=None, kwargs=None)[source]

Apply query.

Parameters:
  • queryset
  • options
  • args
  • kwargs
Returns:

doc_type

Shortcut to the Elasticsearch document type.

Returns:
field_belongs_to(field_name)[source]

Check if given filter field belongs to the backend.

Parameters:field_name
Returns:
filter(queryset)[source]

Filter. This method alters current queryset.

Parameters:queryset
Returns:
classmethod generic_query_fields()[source]

Generic backend specific query fields.

For instance, for search filter backend it would be {'search': String()}.

Returns:
Rtype dict:
get_backend_connection_fields()[source]

Get backend connection fields.

Typical use-case - a backend that alters the Connection object and adds additional fields next to edges and pageInfo (see the graphene_elastic.relay.connection.Connection for more information).

Rtype dict:
Returns:
get_backend_connection_fields_type()[source]

Get backend connection fields type.

Typical use-case - a backend that alters the Connection object and adds additional fields next to edges and pageInfo (see the graphene_elastic.relay.connection.Connection for more information).

Returns:
get_backend_default_query_fields_params()[source]

Get default query fields params for the backend.

Return type:dict
Returns:
get_backend_document_fields()[source]

Get additional document fields for the backend.

For instance, the Highlight backend add additional field named highlight to the list of fields.

Sample query:

query {
allPostDocuments(search:{title:{value:”alice”}}) {
edges {
node {
id title highlight

}

}

}

}

Sample response:

{
“data”: {
“allPostDocuments”: {
“edges”: [
{
“node”: {

“id”: “UG9zdDp5a1ppVlcwQklwZ2dXbVlJQV91Rw==”, “title”: “thus Alice style”, “highlight”: {

“title”: [
“thus <b>Alice</b> style”

]

}

}

]

}

}

}

That highlight part on both sample query and sample response isn’t initially available on the connection level, but added with help of the filter backend. :return:

get_backend_query_fields(items, is_filterable_func, get_type_func)[source]

Construct backend query fields.

Parameters:
  • items
  • is_filterable_func
  • get_type_func
Returns:

get_field_type(field_name, field_value, base_field_type)[source]

Get field type.

Returns:
has_connection_fields = False
has_query_fields = False
prefix = None
classmethod split_lookup_complex_multiple_value(value, maxsplit=-1)[source]

Split lookup complex multiple value.

Parameters:
  • value (str) – Value to split.
  • maxsplit (int) – The maxsplit option of string.split.
Returns:

Lookup filter split into a list.

Return type:

list

classmethod split_lookup_complex_value(value, maxsplit=-1)[source]

Split lookup complex value.

Parameters:
  • value (str) – Value to split.
  • maxsplit (int) – The maxsplit option of string.split.
Returns:

Lookup filter split into a list.

Return type:

list

classmethod split_lookup_filter(value, maxsplit=-1)[source]

Split lookup filter.

Parameters:
  • value (str) – Value to split.
  • maxsplit (int) – The maxsplit option of string.split.
Returns:

Lookup filter split into a list.

Return type:

list

classmethod split_lookup_name(value, maxsplit=-1)[source]

Split lookup value.

Parameters:
  • value (str) – Value to split.
  • maxsplit (int) – The maxsplit option of string.split.
Returns:

Lookup value split into a list.

Return type:

list

Module contents