graphene_elastic.filter_backends package

Subpackages

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:

property 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

graphene_elastic.filter_backends.queries module

class graphene_elastic.filter_backends.queries.Contains(*args, **kwargs)[source]

Bases: String

Wildcard.

filter:[

{category: {contains: “lish”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Direction(*args, **kwargs)

Bases: Enum

ASC = 'asc'
DESC = 'desc'
class graphene_elastic.filter_backends.queries.EndsWith(*args, **kwargs)[source]

Bases: String

Ends with.

filter:[

{category: {endsWith: “dren”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Exclude(*args, **kwargs)[source]

Bases: _ListOfTypeString

Exclude.

filter:[

{category: {exclude: [“Python”, “Django”]}}

]

class graphene_elastic.filter_backends.queries.Exists(*args, **kwargs)[source]

Bases: Boolean

Exists.

filter:[

{category: {exist: true}]}}

]

required = True
class graphene_elastic.filter_backends.queries.GeoBoundingBox(*args, **kwargs)[source]

Bases: InputObjectType

Geo polygon.

filter:[
{place: {geoBoundingBox: {

topLeft: {lat: “40.0”, lon=”70.0”}, bottomRight: {lat: “80.0”, lon: “90.0”}

}}}

]

bottom_right = <graphene.types.field.Field object>
top_left = <graphene.types.field.Field object>
class graphene_elastic.filter_backends.queries.GeoDistance(*args, **kwargs)[source]

Bases: InputObjectType

Geo distance.

filter:[

{place: {geoDistance: {distance: “9km”, lat: “40.0”, lon=”70.0”}}}

]

distance = <graphene.types.scalars.String object>
lat = <graphene.types.decimal.Decimal object>
lon = <graphene.types.decimal.Decimal object>
class graphene_elastic.filter_backends.queries.GeoPolygon(*args, **kwargs)[source]

Bases: InputObjectType

Geo polygon.

filter:[

{place: {geoPolygon: {points: [{lat: “40.0”, lon=”70.0”}]}}}

]

points = <graphene.types.structures.List object>
class graphene_elastic.filter_backends.queries.Gt(*args, **kwargs)[source]

Bases: _NumberOrDate

Gt.

filter:[

{category: {gt: “1”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Gte(*args, **kwargs)[source]

Bases: _NumberOrDate

Gte.

filter:[

{category: {gte: “1”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.In(*args, **kwargs)[source]

Bases: _ListOfTypeString

In.

filter:[

{category: {in: [“Python”, “Django”]}}

]

class graphene_elastic.filter_backends.queries.IsNull(*args, **kwargs)[source]

Bases: Boolean

Is null.

filter:[

{category: {isNull: true}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Lt(*args, **kwargs)[source]

Bases: _NumberOrDate

Lt.

filter:[

{category: {lt: “1”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Lte(*args, **kwargs)[source]

Bases: _NumberOrDate

Lte.

filter:[

{category: {lte: “1”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Point(*args, **kwargs)[source]

Bases: InputObjectType

Point. Helper for many geo lookups.

lat = <graphene.types.decimal.Decimal object>
lon = <graphene.types.decimal.Decimal object>
class graphene_elastic.filter_backends.queries.Prefix(*args, **kwargs)[source]

Bases: String

Prefix.

filter:[

{category: {prefix: “bio”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Range(*args, **kwargs)[source]

Bases: InputObjectType

Range.

filter:[

{range: {lower: “1000”, upper: “2000”, boost: “2.0”}]}}

]

boost = <graphene.types.decimal.Decimal object>
lower = <graphene.types.field.Field object>
upper = <graphene.types.field.Field object>
class graphene_elastic.filter_backends.queries.StartsWith(*args, **kwargs)[source]

Bases: Prefix

Starts with (alias of prefix).

class graphene_elastic.filter_backends.queries.Term(*args, **kwargs)[source]

Bases: String

Terms.

filter:[

{category: {term: “Python”}]}}

]

required = True
class graphene_elastic.filter_backends.queries.Terms(*args, **kwargs)[source]

Bases: _ListOfTypeString

Terms.

filter:[

{category: {terms: [“Python”, “Django”]}}

]

class graphene_elastic.filter_backends.queries.Wildcard(*args, **kwargs)[source]

Bases: String

Wildcard.

filter:[

{category: {wildcard: “bio”}]}}

]

required = True

Module contents