Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7348,13 +7348,13 @@
},
"strict": false
},
"optionalNullable": true
"optionalNullable": false
},
"adv": {
"$ref": "#/components/schemas/AdvancedSearchSettings",
"description": "Advanced search settings",
"default": {},
"optionalNullable": true
"optionalNullable": false
}
},
"type": "object",
Expand Down Expand Up @@ -7720,7 +7720,8 @@
"type": "boolean",
"title": "Defaultactive",
"description": "Whether this resource is active by default when public",
"default": true
"default": true,
"optionalNullable": false
},
"enableContentContext": {
"type": "boolean",
Expand Down Expand Up @@ -7750,7 +7751,8 @@
"type": "boolean",
"title": "Rtl",
"description": "Whether to display text contents in right-to-left direction",
"default": false
"default": false,
"optionalNullable": false
},
"osk": {
"anyOf": [
Expand Down Expand Up @@ -9776,31 +9778,36 @@
"type": "boolean",
"title": "Defaultactive",
"description": "Whether this resource is active by default when public",
"default": true
"default": true,
"optionalNullable": false
},
"enableContentContext": {
"type": "boolean",
"title": "Enablecontentcontext",
"description": "Show combined contents of this resource on the parent level",
"default": false
"default": false,
"optionalNullable": false
},
"searchableQuick": {
"type": "boolean",
"title": "Searchablequick",
"description": "Whether this resource should be included in quick search",
"default": true
"default": true,
"optionalNullable": false
},
"searchableAdv": {
"type": "boolean",
"title": "Searchableadv",
"description": "Whether this resource should accessible via advanced search",
"default": true
"default": true,
"optionalNullable": false
},
"rtl": {
"type": "boolean",
"title": "Rtl",
"description": "Whether to display text contents in right-to-left direction",
"default": false
"default": false,
"optionalNullable": false
},
"osk": {
"anyOf": [
Expand Down Expand Up @@ -11193,7 +11200,7 @@
"pg": 1,
"pgs": 10
},
"optionalNullable": true
"optionalNullable": false
},
"sort": {
"anyOf": [
Expand All @@ -11205,7 +11212,7 @@
}
],
"description": "Sorting preset",
"optionalNullable": true
"optionalNullable": false
},
"strict": {
"type": "boolean",
Expand Down Expand Up @@ -12674,14 +12681,14 @@
"title": "Pg",
"description": "Page number",
"default": 1,
"optionalNullable": true
"optionalNullable": false
},
"pgs": {
"type": "integer",
"title": "Pgs",
"description": "Page size",
"default": 10,
"optionalNullable": true
"optionalNullable": false
}
},
"type": "object",
Expand Down Expand Up @@ -14229,16 +14236,18 @@
},
"strict": false
},
"optionalNullable": true
"optionalNullable": false
},
"qck": {
"$ref": "#/components/schemas/QuickSearchSettings",
"description": "Quick search settings",
"default": {
"op": "OR",
"re": false
"re": false,
"inh": false,
"allLvls": false
},
"optionalNullable": true
"optionalNullable": false
}
},
"type": "object",
Expand All @@ -14255,14 +14264,28 @@
"title": "Op",
"description": "Default operator",
"default": "OR",
"optionalNullable": true
"optionalNullable": false
},
"re": {
"type": "boolean",
"title": "Re",
"description": "Whether to use regular expressions",
"default": false,
"optionalNullable": true
"optionalNullable": false
},
"inh": {
"type": "boolean",
"title": "Inh",
"description": "Whether to match contents inherited from higher-level locations",
"default": false,
"optionalNullable": false
},
"allLvls": {
"type": "boolean",
"title": "Alllvls",
"description": "Whether to find locations from all levels, as opposed to only finding locations from the respective text's default level",
"default": false,
"optionalNullable": false
},
"txt": {
"anyOf": [
Expand Down
3 changes: 2 additions & 1 deletion Tekst-API/tekst/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def log_op_end(
global _running_ops
op_entry = _running_ops.pop(op_id, None)
if op_entry is None: # pragma: no cover
raise RuntimeError(f"Operation {op_id} not found in running operations dict")
log.error(f"Operation {op_id} not found in running operations dict")
return -1
label, start_t, level_code, use_proc_t = op_entry
dur = (process_time() if use_proc_t else perf_counter()) - start_t
if not failed:
Expand Down
7 changes: 6 additions & 1 deletion Tekst-API/tekst/models/resource_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tekst.models.common import ModelBase
from tekst.models.platform import OskKey
from tekst.types import ConStrOrNone
from tekst.types import ConStrOrNone, SchemaOptionalNonNullable


class CommonResourceConfig(ModelBase):
Expand All @@ -29,30 +29,35 @@ class CommonResourceConfig(ModelBase):
Field(
description="Whether this resource is active by default when public",
),
SchemaOptionalNonNullable,
] = True
enable_content_context: Annotated[
bool,
Field(
description="Show combined contents of this resource on the parent level",
),
SchemaOptionalNonNullable,
] = False
searchable_quick: Annotated[
bool,
Field(
description="Whether this resource should be included in quick search",
),
SchemaOptionalNonNullable,
] = True
searchable_adv: Annotated[
bool,
Field(
description="Whether this resource should accessible via advanced search",
),
SchemaOptionalNonNullable,
] = True
rtl: Annotated[
bool,
Field(
description="Whether to display text contents in right-to-left direction",
),
SchemaOptionalNonNullable,
] = False
osk: OskKey | None = None

Expand Down
41 changes: 31 additions & 10 deletions Tekst-API/tekst/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PaginationSettings(ModelBase):
alias="pg",
description="Page number",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = 1
page_size: Annotated[
int,
Expand All @@ -103,7 +103,7 @@ class PaginationSettings(ModelBase):
alias="pgs",
description="Page size",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = 10

def es_from(self) -> int:
Expand All @@ -126,15 +126,15 @@ class GeneralSearchSettings(ModelBase):
alias="pgn",
description="Pagination settings",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = PaginationSettings()
sorting_preset: Annotated[
SortingPreset | None,
Field(
alias="sort",
description="Sorting preset",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = None
strict: bool = False

Expand All @@ -146,15 +146,36 @@ class QuickSearchSettings(ModelBase):
alias="op",
description="Default operator",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = "OR"
regexp: Annotated[
bool,
Field(
alias="re",
description="Whether to use regular expressions",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = False
inherited_contents: Annotated[
bool,
Field(
alias="inh",
description=(
"Whether to match contents inherited from higher-level locations"
),
),
SchemaOptionalNonNullable,
] = False
all_levels: Annotated[
bool,
Field(
alias="allLvls",
description=(
"Whether to find locations from all levels, as opposed to only finding "
"locations from the respective text's default level"
),
),
SchemaOptionalNonNullable,
] = False
texts: Annotated[
list[PydanticObjectId] | None,
Expand Down Expand Up @@ -201,15 +222,15 @@ class QuickSearchRequestBody(ModelBase):
alias="gen",
description="General search settings",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = GeneralSearchSettings()
settings_quick: Annotated[
QuickSearchSettings,
Field(
alias="qck",
description="Quick search settings",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = QuickSearchSettings()


Expand Down Expand Up @@ -237,15 +258,15 @@ class AdvancedSearchRequestBody(ModelBase):
alias="gen",
description="General search settings",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = GeneralSearchSettings()
settings_advanced: Annotated[
AdvancedSearchSettings,
Field(
alias="adv",
description="Advanced search settings",
),
SchemaOptionalNullable,
SchemaOptionalNonNullable,
] = AdvancedSearchSettings()


Expand Down
6 changes: 6 additions & 0 deletions Tekst-API/tekst/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def index_mappings(
strict_analyzer=strict_analyzer,
)
return dict(
native={
"type": "boolean",
},
comment={
"type": "text",
"analyzer": "standard_no_diacritics",
Expand All @@ -176,11 +179,14 @@ def index_mappings(
def index_doc(
cls,
content: ContentBase,
*,
native: bool = True,
) -> dict[str, Any]:
"""
Returns the content for the ES index document for this type of resource content
"""
return dict(
native=native,
comment=content.comment,
**(cls._rtype_index_doc(content) or {}),
)
Expand Down
2 changes: 1 addition & 1 deletion Tekst-API/tekst/routers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def perform_search(
if body.search_type == "quick":
return await search.search_quick(
user=user,
query_string=body.query,
user_query=body.query,
settings_general=body.settings_general,
settings_quick=body.settings_quick,
)
Expand Down
Loading