jina.types.querylang

class jina.types.querylang.QueryLang(querylang=None, copy=False)[source]

Bases: jina.types.mixin.ProtoTypeMixin

QueryLang is one of the primitive data type in Jina.

It offers a Pythonic interface to allow users access and manipulate jina.jina_pb2.QueryLangProto object without working with Protobuf itself.

To create a QueryLang object from a Dict containing the name of a BaseDriver,

and the parameters to override, simply:

from jina import QueryLang
ql = QueryLang({name: 'SliceQL', priority: 1, parameters: {'start': 3, 'end': 1}})

Warning

The BaseDriver needs to be a QuerySetReader to be able to read the QueryLang

One can also build a :class`QueryLang` from JSON string, bytes, dict or directly from a protobuf object.

A QueryLang object (no matter how it is constructed) can be converted to protobuf object by using:

# to protobuf object
ql.as_pb_object
Parameters
  • querylang (Optional[QueryLangSourceType]) – the query language source to construct from, acceptable types include: jina_pb2.QueryLangProto, bytes, str, Dict, Tuple.

  • copy (bool) – when querylang is given as a QueryLangProto object, build a view (i.e. weak reference) from it or a deep copy from it.

Set constructor method.

property priority

Get the priority of this query language. The query language only takes effect when if it has a higher priority than the internal one with the same name

Return type

int

property name

Get the name of the driver that the query language attached to.

Return type

str