dataset¶
This module implements the Dataset class, which binds a Setting to a sayt2 search index and provides build/search operations.
- class afwf_fts_anything.dataset.Dataset(name: str, dir_root: Path)[source]¶
A search dataset backed by a sayt2 index.
Identified by a name and a dir_root directory that owns all dataset resources under a shared convention:
{dir_root}/{name}-setting.json– field schema and display config{dir_root}/{name}-data.json– the records to index{dir_root}/{name}-index/– sayt2 index directory (auto-created){dir_root}/icons/{name}.png– per-result icons (resolved on demand)
- get_data() list[dict][source]¶
Read records from the local data JSON file.
If the file does not exist,
download_data()is called first.
- get_sayt2_dataset() DataSet[source]¶
Create a
sayt2.DataSetwired to this dataset’s index and setting.
- download_data() None[source]¶
Download the dataset from
Setting.data_urland save it locally.Raises
ValueErrorifdata_urlis not configured.
- build_index(data: list[dict[str, Any]] | None = None, rebuild: bool = False) int[source]¶
Build the sayt2 search index from data.
- Parameters:
data – records to index; if
Nonethe configured downloader is used.rebuild – if
True, evict the query cache before building so subsequent searches always reflect the new index.
- Returns:
number of documents indexed.