jina.types.querylang¶
-
class
jina.types.querylang.
QueryLang
(querylang=None, copy=False)[source]¶ Bases:
object
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 aBaseDriver
object, simply:from jina import QueryLang from jina.drivers.querylang.slice import SliceQL s = SliceQL(start=3, end=4) ql = QueryLang(s)
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 or back to driver object by using:# to protobuf object s.as_pb_object # to driver object s.as_driver_object
To get the class name of the associated driver, one can use
driver
.- Parameters
querylang (
Optional
[~QueryLangSourceType]) – the query language source to construct from, acceptable types include:jina_pb2.QueryLangProto
,bytes
,str
,Dict
,BaseDriver
.copy (
bool
) – whenquerylang
is given as aQueryLangProto
object, build a view (i.e. weak reference) from it or a deep copy from it.
-
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
-
property
driver
¶ Get the driver class that the query language attached to
- ..warning::
This browses all module trees and can be costly, do not frequently call it.
- Return type
Type
[BaseDriver
]
-
property
as_pb_object
¶ Return a protobuf
jina_pb2.QueryLangProto
object- Return type
QueryLangProto
-
property
as_driver_object
¶ Return a
BaseDriver
object- Return type