Skip to content

Commit

Permalink
Enable configring which resources are searchable with quick search
Browse files Browse the repository at this point in the history
Closes #286
  • Loading branch information
bkis committed Sep 18, 2024
1 parent ffff7e0 commit bf9b097
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 23 deletions.
42 changes: 36 additions & 6 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7366,7 +7366,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -7520,6 +7521,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -7737,6 +7739,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -7916,6 +7919,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -8481,6 +8485,12 @@
"title": "Showonparentlevel",
"description": "Show combined contents of this resource on the parent level",
"default": false
},
"quickSearchable": {
"type": "boolean",
"title": "Quicksearchable",
"description": "Whether this resource should be included in quick search",
"default": true
}
},
"type": "object",
Expand Down Expand Up @@ -9025,7 +9035,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -9179,6 +9190,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -9396,6 +9408,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -9575,6 +9588,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -10097,7 +10111,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -10251,6 +10266,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -10468,6 +10484,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -10647,6 +10664,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -11426,7 +11444,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -11597,6 +11616,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -11825,6 +11845,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -12015,6 +12036,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -13156,7 +13178,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -13310,6 +13333,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -13527,6 +13551,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -13706,6 +13731,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -14290,7 +14316,8 @@
"default": {
"sortOrder": 10,
"defaultActive": true,
"showOnParentLevel": false
"showOnParentLevel": false,
"quickSearchable": true
}
},
"general": {
Expand Down Expand Up @@ -14465,6 +14492,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -14704,6 +14732,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down Expand Up @@ -14905,6 +14934,7 @@
"default": {
"common": {
"defaultActive": true,
"quickSearchable": true,
"showOnParentLevel": false,
"sortOrder": 10
},
Expand Down
6 changes: 6 additions & 0 deletions Tekst-API/tekst/models/resource_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class CommonResourceConfig(ModelBase):
description="Show combined contents of this resource on the parent level",
),
] = False
quick_searchable: Annotated[
bool,
Field(
description="Whether this resource should be included in quick search",
),
] = True


class ResourceConfigBase(ModelBase):
Expand Down
5 changes: 3 additions & 2 deletions Tekst-API/tekst/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ async def search_quick(
field_pattern_suffix = ".strict" if settings_general.strict else ""
fields = []
for res_id, res in target_resources.items():
for field in res.quick_search_fields():
fields.append(f"resources.{res_id}.{field}{field_pattern_suffix}")
if res.config.common.quick_searchable:
for field in res.quick_search_fields():
fields.append(f"resources.{res_id}.{field}{field_pattern_suffix}")

# compose the query
if not settings_quick.regexp or not query_string:
Expand Down
Loading

0 comments on commit bf9b097

Please sign in to comment.