Coverage for documents/search/_fields.py: 100%
5 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 09:07 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 09:07 +0000
1from __future__ import annotations
3from whoosh_compat import FieldKind
4from whoosh_compat import FieldSpec
5from whoosh_compat import SubpathSpec
7# Internal-only schema fields with no query-syntax meaning of their own
8# (sort shadow fields, bigram CJK fields, simple_title/simple_content,
9# autocomplete_word, notes_text) are NOT represented here, they are
10# declared in _schema.py's field_descriptors().
11#
12# analyzer/pattern_normalizer are deliberately left at FieldSpec's default
13# (None): they're language-specific and only meaningful to whoosh-compat's
14# parser, so _registry.py attaches them per-language via dataclasses.replace()
15# rather than PUBLIC_FIELDS declaring them itself. _schema.py only reads
16# name/kind/fast and never sees the analyzer at all.
17PUBLIC_FIELDS: tuple[FieldSpec, ...] = (
18 FieldSpec("title", FieldKind.TEXT),
19 FieldSpec("content", FieldKind.TEXT),
20 FieldSpec("correspondent", FieldKind.TEXT),
21 FieldSpec("document_type", FieldKind.TEXT, aliases=("type",)),
22 FieldSpec("storage_path", FieldKind.TEXT, aliases=("path",)),
23 FieldSpec("original_filename", FieldKind.TEXT),
24 FieldSpec("tag", FieldKind.TEXT, comma_values=True),
25 FieldSpec("checksum", FieldKind.KEYWORD),
26 FieldSpec("asn", FieldKind.U64, fast=True),
27 FieldSpec("page_count", FieldKind.U64, fast=True),
28 FieldSpec("num_notes", FieldKind.U64, fast=True),
29 FieldSpec("created", FieldKind.DATE, date_only=True, fast=True),
30 FieldSpec("modified", FieldKind.DATETIME, fast=True),
31 FieldSpec("added", FieldKind.DATETIME, fast=True),
32 FieldSpec(
33 "notes",
34 FieldKind.JSON,
35 subpaths={"user": SubpathSpec(), "note": SubpathSpec(default=True)},
36 ),
37 FieldSpec(
38 "custom_fields",
39 FieldKind.JSON,
40 subpaths={"name": SubpathSpec(), "value": SubpathSpec(default=True)},
41 ),
42 FieldSpec(
43 "barcodes",
44 FieldKind.JSON,
45 subpaths={"value": SubpathSpec(default=True), "format": SubpathSpec()},
46 ),
47)