muspan.query.query_container#
- class query_container(query1=None, operator=None, query2=None, domain=None, bypass_checks=False)#
A helper class to standardize formatting of boolean queries.
Each muspan query can be interpreted (using interpret_query) as an array of object indices that match the criteria. query_container provides infrastructure to stack multiple queries which can be interpreted simultaneously. Hence, a query_container can be used to apply the same (complex) query in different functions without requiring the user to write the query multiple times.
- Attributes:
- queriestuple
A tuple representing the stacked queries.
- plaintext_stringstr
A string representation of the query for easy readability.
Methods
- __init__(query1=None, operator=None, query2=None, domain=None, bypass_checks=False)#
Initialise query_container
- Parameters:
- query1tuple or muspan.query object
The first query-like object.
- operatorstr
Logical operation with which to combine the two queries. Options are “AND”, “OR”, or “AND NOT”.
- query2tuple or muspan.query object
The second query-like object.
- domainmuspan.domain object, optional
A muspan domain associated with this query. Required if passing queries in tuple form. Defaults to None.
- bypass_checksbool, optional
If True, standard checks on whether this query can be interpreted are bypassed. May generate unexpected crashes if objects that can’t be interpreted as a query are passed in, but generates a substantial speed increase for large datasets when we’re confident the query is formatted correctly. Defaults to False.
Methods
add_query
(query1, operator, query2[, ...])Add a combination of queries into the query container
- add_query(query1, operator, query2, domain=None, bypass_checks=False)#
Add a combination of queries into the query container
- Parameters:
- query1tuple or muspan.query object
The first query-like object.
- operatorstr
Logical operation with which to combine the two queries. Options are “AND”, “OR”, or “AND NOT”.
- query2tuple or muspan.query object
The second query-like object.
- domainmuspan.domain object, optional
A muspan domain associated with this query. Required if passing queries in tuple form. Defaults to None.
- bypass_checksbool, optional
If True, standard checks on whether this query can be interpreted are bypassed. May generate unexpected crashes if objects that can’t be interpreted as a query are passed in, but generates a substantial speed increase for large datasets when we’re confident the query is formatted correctly. Defaults to False.