Search Module

Search Client

class citrination_client.search.client.SearchClient(api_key, webserver_host='https://citrination.com', suppress_warnings=False, proxies=None)

Bases: citrination_client.base.base_client.BaseClient

__init__(api_key, webserver_host='https://citrination.com', suppress_warnings=False, proxies=None)

Constructor.

Run a dataset query against Citrination.

Parameters

dataset_returning_query (DatasetReturningQuery) – DatasetReturningQuery to execute.

Returns

Dataset search result object with the results of the query.

Return type

DatasetSearchResult

generate_simple_chemical_query(name=None, chemical_formula=None, property_name=None, property_value=None, property_min=None, property_max=None, property_units=None, reference_doi=None, include_datasets=[], exclude_datasets=[], from_index=None, size=None)

This method generates a PifSystemReturningQuery object using the supplied arguments. All arguments that accept lists have logical OR’s on the queries that they generate. This means that, for example, simple_chemical_search(name=[‘A’, ‘B’]) will match records that have name equal to ‘A’ or ‘B’.

Results will be pulled into the extracted field of the PifSearchHit objects that are returned. The name will appear under the key “name”, chemical formula under “chemical_formula”, property name under “property_name”, value of the property under “property_value”, units of the property under “property_units”, and reference DOI under “reference_doi”.

This method is only meant for execution of very simple queries. More complex queries must use the search method that accepts a PifSystemReturningQuery object.

Parameters
  • name (str or list of str) – One or more strings with the names of the chemical system to match.

  • chemical_formula (str or list of str) – One or more strings with the chemical formulas to match.

  • property_name (str or list of str) – One or more strings with the names of the property to match.

  • property_value (str or int or float or list of str or int or float) – One or more strings or numbers with the exact values to match.

  • property_min (str or int or float) – A single string or number with the minimum value to match.

  • property_max (str or int or float) – A single string or number with the maximum value to match.

  • property_units (str or list of str) – One or more strings with the property units to match.

  • reference_doi – One or more strings with the DOI to match.

  • include_datasets (int or list of int) – One or more integers with dataset IDs to match.

  • exclude_datasets (int or list of int) – One or more integers with dataset IDs that must not match.

  • from_index (int) – Index of the first record to match.

  • size (int) – Total number of records to return.

Returns

A query to to be submitted with the pif_search method

Return type

PifSystemReturningQuery

Run each in a list of PIF queries against Citrination.

Parameters

multi_queryMultiQuery object to execute.

Returns

PifMultiSearchResult object with the results of the query.

Run a PIF query against Citrination.

Parameters

pif_system_returning_query (PifSystemReturningQuery) – The PIF system query to execute.

Returns

PifSearchResult object with the results of the query.

Return type

PifSearchResult

Query Encoder

class citrination_client.search.query_encoder.QueryEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.encoder.JSONEncoder

Class used to convert a query to json.

default(obj)

Convert an object to a form ready to dump to json.

Parameters

obj – Object being serialized. The type of this object must be one of the following: None; a single object derived from the Pio class; or a list of objects, each derived from the Pio class.

Returns

List of dictionaries, each representing a physical information object, ready to be serialized.