File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,35 @@ wikitool search "mars" --output json
8181| ` -l, --lang ` | Wikipedia language code (default: ` en ` ) |
8282| ` -o, --output ` | Output format: ` text ` , ` json ` , ` html ` (default: ` text ` ) |
8383
84+ ## Search Syntax
85+
86+ Wikipedia uses CirrusSearch (Elasticsearch-based), which supports advanced query syntax:
87+
88+ | Syntax | Example | Description |
89+ | --------| ---------| -------------|
90+ | ` "phrase" ` | ` "theory of relativity" ` | Exact phrase match |
91+ | ` intitle: ` | ` intitle:einstein ` | Search only in page titles |
92+ | ` incategory: ` | ` incategory:"Nobel laureates" ` | Filter by category |
93+ | ` * ` | ` einst* ` | Wildcard prefix matching |
94+ | ` ~ ` | ` quantim~ ` | Explicit fuzzy match (typo-tolerant by default) |
95+ | ` - ` | ` einstein -albert ` | Exclude term from results |
96+ | ` OR ` | ` einstein OR feynman ` | Boolean OR |
97+ | ` hastemplate: ` | ` hastemplate:Infobox ` | Pages using a specific template |
98+
99+ ``` bash
100+ # Phrase search
101+ wikitool search ' "theory of relativity"'
102+
103+ # Title-only search
104+ wikitool search " intitle:einstein"
105+
106+ # Exclude terms
107+ wikitool search " physics -quantum"
108+
109+ # Category filter
110+ wikitool search ' incategory:"Physics" waves'
111+ ```
112+
84113## License
85114
86115GPL-3.0 - see [ LICENSE] ( LICENSE )
Original file line number Diff line number Diff line change @@ -20,10 +20,23 @@ var searchCmd = &cobra.Command{
2020
2121By default, searches page content. Use --title for title autocomplete.
2222
23+ The search supports CirrusSearch query syntax:
24+ "exact phrase" Exact phrase match
25+ intitle:word Search only in titles
26+ incategory:"Name" Filter by category
27+ prefix* Wildcard prefix matching
28+ word~ Fuzzy matching (typo-tolerant by default)
29+ -exclude Exclude term from results
30+ word1 OR word2 Boolean OR
31+ hastemplate:Name Pages using a specific template
32+
2333Examples:
2434 wikitool search "solar system"
2535 wikitool search "quantum" --limit 20
26- wikitool search "einst" --title --lang de` ,
36+ wikitool search "einst" --title --lang de
37+ wikitool search "intitle:einstein"
38+ wikitool search "physics -quantum"
39+ wikitool search '"theory of relativity"'` ,
2740 Args : cobra .ExactArgs (1 ),
2841 RunE : runSearch ,
2942}
You can’t perform that action at this time.
0 commit comments