Action: search
Search — the
{{search}} action searches the content of the wiki.Union search: the results include the pages that match any of the whitespace-separated keywords (
MATCH … AGAINST … IN BOOLEAN MODE for the body, combined with LIKE lower for title, tag, description and keywords).Attention: the union behaviour depends on the database engine.
- MySQL / MariaDB: the body is searched with the full-text index in boolean mode, where several words without operators are combined with OR. The operators
+,-,>,<,~,*,",(,)are effective here. - SQLite: the body is searched in the FTS5 virtual table
page_fts, where the search phrase is inserted as a quoted literal phrase. Several words must therefore occur consecutively, and no boolean operators are supported. The tablepage_ftsmust exist; it is created by theadminupdateaction. - In both cases title, tag, description and keywords are additionally searched with a case-insensitive substring comparison of the whole phrase (
LIKE lower). The boolean operators do not work there – the phrase is used literally.
Other details:
- The search is executed only from 3 characters of the search phrase; with a shorter phrase neither results nor a message are displayed.
- In MySQL mode the results are sorted by relevance (
ORDER BY score DESC); in SQLite mode they are returned unsorted. - The number of results shown is the total number of matches, also including pages the current user may not be allowed to read.
- The preview of the matching passage is generated only in the full-text mode, shows up to 4 matching lines and is truncated to 500 characters.
1. Syntax
- Call:
{{search [phrase="Term"] [page="PageName"] [options=0|1] [topic=1] [form=1] [lang="en"] [hl_simple=0] [max=10] [nomark=0] [style=one of ("br","ul","ol","comma")] [scope=one of ("pages", "all")]}} -
phrasesearch term (at least 3 characters); can also be given in the query string as?phrase=... -
pagerestricts the search to the subpages of the specified namespace/cluster; the cluster page itself is not part of the result. Usepage="/"(or leave it empty) to search all clusters. -
options- with the value 0 only the search field is displayed, other options and filters are hidden (default is 1: language selection and the "only in page names" option are shown) -
topicif it is advanced into 1, the search occurs only on the names (tag) and titles of pages; otherwise both on the names/titles and on the texts of the pages. The option is also switched on by the mere presence of?topicin the query string. -
formthe search form is displayed when no search phrase is given; as soon as a phrase is present the form is hidden automatically (the parameter itself has no effect). -
langsearches only in pages of the given language (also possible via?lang=…); an unknown language code is ignored. -
hl_simplewith the value 1 the whole search phrase is highlighted (including partial matches); by default (0) only complete words are highlighted. -
scopeanswers for that, where to search: only in the pages ("pages") or in the commentaries also ("all", default). Every value other than "pages" is treated as "all". -
max- overwrites the system default value (default is 10) -
nomark, advanced in one, makes it possible to hide the frame (and the result header) around the results of the search. -
styleanswers for the exterior view of results:"br","ul","ol"(default) or"comma"; an unknown value falls back to"ol". - All parameters are optional.
Further filters passed through the query string and used by the search form:
?category_id=… (restrict to pages of a category), ?lang=…, ?topic.To display the built-in help of this action use
{{search help=1}}.2. Boolean Search Operators
TheMATCH AGAINST clause in MySQL, when used with the IN BOOLEAN MODE modifier, supports several operators to refine search queries. These operators include:-
+(mandatory inclusion): The word following the plus sign must be present in the result. -
-(exclusion): The word following the minus sign must not be present in the result. -
>(increase ranking): The word following the greater-than sign is included, and its ranking value is increased. -
<(decrease ranking): The word following the less-than sign is included, and its ranking value is decreased. -
()(grouping): Parentheses are used to group words into subexpressions, allowing them to be treated as a single unit for inclusion, exclusion, or ranking. -
~(negate ranking): The ranking value of the word following the tilde is negated. -
*(wildcard): The asterisk serves as a truncation (or wildcard) operator, where words matching the prefix of the word preceding the asterisk are included. For example,sql*finds words like "sql", "sqlite", etc.. -
"(phrase matching): Double quotes are used to define a phrase, requiring the entire phrase to be matched for inclusion or exclusion. - [no operator] implies OR
These operators allow for complex and powerful searches, making the boolean mode suitable for experienced users who need precise control over search results.
Caveats:
- The operators are effective only in the full-text (body) part of the MySQL/MariaDB query. In the title/tag/description/keywords part the phrase is used as a literal substring, so an expression like
+wordwill not match anything there. - With SQLite (FTS5) the phrase is searched as a literal quoted phrase; none of the operators is interpreted.
- MySQL/MariaDB may ignore very frequent words (stopword-like behaviour), depending on the storage engine and the content of the wiki.
- The operator characters have a special meaning only in the body search; to look for them literally use the quoted phrase or the plain (non-regex) search.
2.1. Resources
- Boolean Full-Text Searches[link1]
- MariaDB: Regular Expressions[link2]
- https://mariadb.com/docs/serve[...]-text-index-overview[link3]
3. Examples
{{search phrase="BadBehaviour" page="/"}}Search results for «BadBehaviour» (31):
-
Action: search[link4]
action, search -
5.5 Release Notes[link5]
audio, video and SVG files 1. added Bad Behaviour (/Dev/Components/Lib/BadBehaviour) as extension 1. public registration moderation by admin 1. using password_hash() ...
release, release notes -
5.5 Change Log[link6]
Extensions 1. added Bad Behavior (/Dev/Components/Lib/BadBehaviour) extension
change log, release -
Bad Behaviour[link7]
see ((/Dev/Components/Lib/BadBehaviour))- copy tool_badbehaviour.php to admin/module/ to see logs
admin panel, bad behaviour, security, spam -
6.0 Change Log[link8]
updated * Bad Behavior (https:github.com/Bad-Behaviour/badbehaviour) 2.2.24 * clipboard.js (https:github.com/zenorocha/clipboard.js) v2.0.11 * Hashids (https:hashids.org/php/) ...
change log
4. See also
- Binary string search[link9] - allows users to do a string search using exact or regex search.
- [link1] https://dev.mysql.com/doc/refman/8.4/en/fulltext-boolean.html
- [link2] https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regular-expressions-overview
- [link3] https://mariadb.com/docs/server/ha-and-performance/optimization-and-tuning/optimization-and-indexes/full-text-indexes/full-text-index-overview
- [link4] https://wackowiki.org/doc/Doc/English/Actions/Search
- [link5] https://wackowiki.org/doc/Dev/Release/R5.5/ReleaseNotes
- [link6] https://wackowiki.org/doc/Dev/Release/R5.5/ChangeLog
- [link7] https://wackowiki.org/doc/Forum/Integrations/BadBehaviour
- [link8] https://wackowiki.org/doc/Dev/Release/R6.0/ChangeLog
- [link9] https://wackowiki.org/doc/Dev/PatchesHacks/BinaryStringSearch