search_query.query

Query class.

Classes

Query(value, *[, operator, search_field, ...])

Query class.

SearchField(value, *[, position])

SearchField class.

class search_query.query.Query(value: str, *, operator: bool = True, search_field: SearchField | None = None, children: List[str | Query] | None = None, position: Tuple[int, int] | None = None, platform: str = 'generic')

Bases: object

Query class.

add_child(child: str | Query) Query

Add a child Query node and set its parent pointer.

property children: List[Query]

Children property.

copy() Query

Return a deep copy of the Query instance without parent references.

classmethod create(value: str, *, operator: bool = True, search_field: SearchField | None = None, children: List[str | Query] | None = None, position: Tuple[int, int] | None = None, platform: str = 'generic', distance: int = 0) Query

Factory method for query creation.

evaluate(records_dict: dict) dict

Evaluate the query against records using colrev_status labels.

  • rev_included: relevant

  • rev_excluded / rev_prescreen_excluded: irrelevant

  • others: ignored

get_nr_leaves() int

Returns the number of leaves in the query tree

get_parent() Query | None

Return the parent Query node, or None if this node is the root.

get_root() Query

Return the root of the query tree by climbing up parent pointers.

is_term() bool

Check whether the SearchQuery is a term.

property operator: bool

Operator property.

property platform: str

Platform property.

replace(new_query) None
property search_field: SearchField | None

Search field property.

selects(*, record_dict: dict) bool

Indicates whether the query selects a given record.

selects_record(record_dict: dict) bool

Abstract method to be implemented by subclasses to select records.

set_platform_unchecked(platform: str, silent: bool = False) None

Set the platform for this query node without validation. This is an optional utility for parsers.

to_generic_string() str

Prints the query in generic syntax

to_string() str

Prints the query as a string

to_structured_string() str

Prints the query in generic syntax

translate(target_syntax: str) Query

Translate the query to the target syntax using the provided translator.

property value: str

Value property.