Help for tagging (search) added.

This commit is contained in:
Dirk Alders 2024-10-11 14:39:25 +02:00
parent d81c2df678
commit 6a401f322f
2 changed files with 7 additions and 5 deletions

View File

@ -42,12 +42,13 @@ ACCESS = mycreole.render_simple(_("""
SEARCH = mycreole.render_simple(_(
"""
= Search
The search looks up full words in //title (page basename)// and //page_src (the creole source)// without giving \
special search commands in the search string.
The search looks up full words in //title (page basename)//, //page_src (the creole source)// and //tag (page tags)// \
without giving special search commands in the search string.
=== Search fields
* title (TEXT)
* page_src (TEXT)
* tag (TEXT)
* creation_time (DATETIME)
* modified_time (DATETIME)
* modified_user (TEXT)
@ -80,6 +81,7 @@ This search pattern can also be combined with other search text via logical oper
== Examples
* [[/search/?q=modified_user:system-page|modified_user:system-page]] results in a list of all system pages.
* [[/search/?q=modified_time%3A%5B-5d+to+now%5D| modified_time:[-5d to now] ]] results in a list of all pages which have been modified within the last 5 days.
* [[/search/?q=tag%3Afoo| tag:foo ]] results in a list of all pages which are tagged with //foo//.
"""))
BACKUP = mycreole.render_simple(_(

View File

@ -18,7 +18,7 @@ SCHEMA = Schema(
# Page
title=TEXT,
page_src=TEXT,
page_tags=TEXT,
tag=TEXT,
# metadata
creation_time=DATETIME,
modified_time=DATETIME,
@ -64,7 +64,7 @@ def add_item(ix, bp: base_page):
#
title=bp.title,
page_src=bp.raw_page_src,
page_tags=bp.page_tags,
tag=bp.page_tags,
#
creation_time=datetime.fromtimestamp(bp._meta_data.get(bp._meta_data.KEY_CREATION_TIME)),
modified_time=datetime.fromtimestamp(bp._meta_data.get(bp._meta_data.KEY_MODIFIED_TIME)),
@ -79,7 +79,7 @@ def add_item(ix, bp: base_page):
def whoosh_search(search_txt):
ix = load_index()
qp = qparser.MultifieldParser(['title', 'page_src', 'page_tags'], ix.schema)
qp = qparser.MultifieldParser(['title', 'page_src', 'tag'], ix.schema)
qp.add_plugin(DateParserPlugin(free=True))
try:
q = qp.parse(search_txt)