search_query

Top-level package for SearchQuery.

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

Bases: Query

AND Query

property children: List[Query]

Children property.

selects_record(record_dict: dict) bool

Abstract method to be implemented by subclasses to select records.

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

Bases: Query

NEAR Query

property children: List[Query]

Children property.

property distance: int | None

Distance property.

selects_record(record_dict: dict) bool

Check if the record matches the NEAR query.

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

Bases: Query

OR Query Class

property children: List[Query]

Children property.

selects_record(record_dict: dict) bool

Abstract method to be implemented by subclasses to select records.

class search_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.

class search_query.SearchFile(search_string: str, platform: str, authors: list[dict] | None = None, record_info: dict | None = None, date: dict | None = None, filepath: str | Path | None = None, **kwargs: dict)

Bases: object

SearchFile class.

save(filepath: str | Path | None = None) None

Save the search file to a JSON file.

to_dict() dict

Convert the search file to a dictionary.

search_query.load_search_file(filepath: str | Path) SearchFile

Load a search file from a JSON file.

Modules

cli

CLI for search-query.

constants

Constants for search-query

database

Database and filters.

database_queries

Database and filters.

ebsco

Top-level package for EBSCOHost.

exception

Exceptions of SearchQuery.

generic

Top-level package for generic queries.

linter

Query linter hook.

linter_base

Validator for search queries.

parser

Query parser.

parser_base

Base query parser.

pubmed

Top-level package for PubMed.

query

Query class.

query_and

AND Query

query_near

NEAR Query

query_not

NOT Query

query_or

OR Query

query_range

Range Query

query_term

Query class.

search_file

SearchFile parser.

serializer_base

Pubmed serializer.

serializer_structured

Structured serializer.

translator_base

Pubmed query translator.

utils

Utilities for SearchQuery.

wos

Top-level package for WoS.