nakb package

Submodules

nakb.core module

Core module providing a Python client for querying the NAKB Solr API.

class nakb.core.NAKBClient(base_url: str = 'https://nakb.org/node/solr/nakb/select')[source]

Bases: object

get_fields()[source]

Retrieve the list of available fields in NAKB.

This method performs a minimal query and returns the column names of the resulting DataFrame, which correspond to metadata fields stored in the Solr index.

Returns

list[str]

List of available field names in NAKB.

query(fields: list[str] | None = None, rows: int = 10, **kwargs)[source]

High-level query interface for NAKB.

This method provides a Pythonic interface over Solr’s query system. It automatically builds Solr filter queries (fq) based on keyword arguments, supporting operators such as:

  • field__lt=valuefield:[* TO value]

  • field__gt=valuefield:[value TO *]

  • field__range=(a, b)field:[a TO b]

  • field__contains=substrfield:*substr*

  • field="value" → exact match

  • field=[v1, v2, ...] → OR query (field:( "v1" OR "v2" ))

Parameters

fieldslist[str] or None, optional

List of fields to return. If None, Solr returns all fields.

rowsint, optional

Number of rows to retrieve. Default is 10.

**kwargs

Field filters encoded using either direct matches or extended operators.

Returns

pandas.DataFrame

A DataFrame containing the matching rows.

Raises

ValueError

If an unsupported operator is used in a keyword argument.

query_raw(q: str = '*:*', fl: str | None = None, fq: list[str] | str | None = None, rows: int = 10, as_dataframe: bool = True)[source]

Send a raw Solr query to NAKB.

This method sends a direct query to the Solr backend, exposing all parameters such as q (query string), fl (field list), and fq (filter queries). It is a low-level interface; for a more ergonomic wrapper, use query().

Parameters

qstr, optional

Main Solr query string. Defaults to "*:*" (match all entries).

flstr or None, optional

Comma-separated list of fields to return. If None, Solr returns all fields.

fqlist of str, str, or None, optional

Filter query/queries passed directly to Solr. May be a single string or a list of strings. If None, Solr applies no filters.

rowsint, optional

Maximum number of rows to return. Default is 10.

as_dataframebool, optional

If True, results are returned as a pandas.DataFrame. Otherwise, returns the raw list of document dictionaries.

Returns

pandas.DataFrame or list[dict]

Query results, either as a DataFrame (default) or as a list of dicts.

Raises

requests.HTTPError

If the Solr request returns a non-successful status code.

Module contents

Top-level package for : python-nakb

class nakb.NAKBClient(base_url: str = 'https://nakb.org/node/solr/nakb/select')[source]

Bases: object

get_fields()[source]

Retrieve the list of available fields in NAKB.

This method performs a minimal query and returns the column names of the resulting DataFrame, which correspond to metadata fields stored in the Solr index.

Returns

list[str]

List of available field names in NAKB.

query(fields: list[str] | None = None, rows: int = 10, **kwargs)[source]

High-level query interface for NAKB.

This method provides a Pythonic interface over Solr’s query system. It automatically builds Solr filter queries (fq) based on keyword arguments, supporting operators such as:

  • field__lt=valuefield:[* TO value]

  • field__gt=valuefield:[value TO *]

  • field__range=(a, b)field:[a TO b]

  • field__contains=substrfield:*substr*

  • field="value" → exact match

  • field=[v1, v2, ...] → OR query (field:( "v1" OR "v2" ))

Parameters

fieldslist[str] or None, optional

List of fields to return. If None, Solr returns all fields.

rowsint, optional

Number of rows to retrieve. Default is 10.

**kwargs

Field filters encoded using either direct matches or extended operators.

Returns

pandas.DataFrame

A DataFrame containing the matching rows.

Raises

ValueError

If an unsupported operator is used in a keyword argument.

query_raw(q: str = '*:*', fl: str | None = None, fq: list[str] | str | None = None, rows: int = 10, as_dataframe: bool = True)[source]

Send a raw Solr query to NAKB.

This method sends a direct query to the Solr backend, exposing all parameters such as q (query string), fl (field list), and fq (filter queries). It is a low-level interface; for a more ergonomic wrapper, use query().

Parameters

qstr, optional

Main Solr query string. Defaults to "*:*" (match all entries).

flstr or None, optional

Comma-separated list of fields to return. If None, Solr returns all fields.

fqlist of str, str, or None, optional

Filter query/queries passed directly to Solr. May be a single string or a list of strings. If None, Solr applies no filters.

rowsint, optional

Maximum number of rows to return. Default is 10.

as_dataframebool, optional

If True, results are returned as a pandas.DataFrame. Otherwise, returns the raw list of document dictionaries.

Returns

pandas.DataFrame or list[dict]

Query results, either as a DataFrame (default) or as a list of dicts.

Raises

requests.HTTPError

If the Solr request returns a non-successful status code.