Jump to navigation Jump to search

Historically MediaWiki uses and extends the Lucene search engine, and now with CirrusSearch, it wraps Lucene with ElasticSearch. CirrusSearch became available July 2013, and the Wikimedia Foundation migrated to CirrusSearch from MWSearch by late 2014[1] because CirrusSearch makes several key advances.

  • Faster updates to the search indexes: changes to articles are reflected in search results much more quickly.
  • Search index for templates: Template wordings and subtemplate naming are attributed at each page.
  • Better support for searching in different languages.
  • Regular expression searches.

There are seven additional search parameters, and new syntax and arguments in the other four parameters and in the search words and phrases. In order to document all this exquisite control we cover the prerequisite concepts of an "indexed search" and of "page ranking". For its renewed importance in regexp searches, we reintroduce the idea of one search creating the search domain for anther term in the same query.

If your question is not answered here, please ask on the talk page.

Full text search[edit]

A "full text search" is an "indexed search". All pages are stored in the wiki database, and all the words in them are stored in the search database, which is an index to the full text of the wiki. Each visible word is indexed to the list of pages where it is found, so a search for a word is as fast as looking up a single-record.[2] Furthermore, for any changes in wording, the search index is updated within seconds.


  • Templates are now indexed. If the transcluded words of a template change, then all the pages that transclude it are updated. (This can take a long while depending on a job queue.) If the subtemplates used by a template change, the index is updated.
  • Document content that is stored in the File/Media namespace are now indexed. Thousands of formats are recognized.

There is support for dozens of languages currently, but inclusion of all languages is desired. You can find a list of currently supported languages at See their documentation on contributing to submit requests or patches.


Search results will often be accompanied by various preliminary reports including Did you mean (spelling correction), and, when no results would otherwise be found it will say Showing results for (query correction) search instead for (your query).

Search features also include

  • sorting navigation suggestions by the number of incoming links.
  • Words and phrases that match are highlighted in bold on the search results page.[3]

Words, phrases, and modifiers[edit]


  • a string of digits
  • a string of letters
  • subwords between letters/digit transitions, such as in txt2regex
  • subwords inside a compoundName using camelCase


A given search term matches against content (rendered on the page). To match against wikitext instead, use the insource search parameter. Each search parameter has its own index, and interpret its given term in its own way.[5]

Spacing between words, phrases, parameters, and input to parameters can include generous instances of whitespace and greyspace characters. "Greyspace characters" are all the non-alphanumeric characters ~!@#$%^&*()_+-={}|[]\:";'<>?,./. A mixed string of greyspace characters and whitespace characters, is "greyspace", and is one big word boundary. Greyspace is how indexes are made and queries are interpreted.[6]

Two exceptions are where 1) an embedded:colon is one word (it being treated as a letter), and 2) an embedded comma, such as in 1,2,3, is treated as a number Greyspace characters are otherwise ignored unless, due to query syntax, they can be interpreted as modifier characters.


  • A tilde ~ character prefixing a query guarantees search results instead of any possible navigation.
  • A wildcard character inside a word can be a question ? mark for one character or an asterisk * character for more.


  • Stop words are enabled for the edge cases (in the periphery) of a grey_space or camelCase phrase. For example the_invisible_hand_of_a will match meetings invisible hand shake.



  • An "exact phrase" "in quotes" will tolerate (match) with greyspace. Given "exact_phrase" or "exact phrase"it matches "exact]phrase".
  • A greyspace_phrase initiates stemming and stop word checks.
  • Given CamelCase it will additionally match camelcase, all lowercase. CirrusSearch is case insensitive.

A word search will "additionally" find the words anywhere on the page.

Some parameters interpret greyspace phrases, but other paramters, like insource only interpret the usual "phrase in quotes".

parserfunction parserFunction parser function parser-function parser:function parSer:funcTion Note
parserfunction N N N N Case insensitive
"parser function" N N N N Case insensitive
parser_function N N N Case insensitive
parserFunction N N Case insensitive
"parser:function" N N N N Case insensitive
"parser_function" N N N N Case insensitive
"parSer_funcTion" N N N N Case insensitive
parSer_FuncTion N N Case insensitive








From the table we can surmise that the basic search parser_function -"parser function" is the sum of the basic searches parserFunction and parse<stems> function<stems>.

Making inquiries with numbers, we would find that

  • Plan9 or Plan_9 matches any of: plan9, plans 9, planned 9th, (planned) 9200, "plans" (9:24)
  • "plan9" only matches plan9 (case insensitive)
  • Plan*9 matches plan9 or planet4589.

The wildcard * character is basic and matches within a rendered word. It ignores the first (one or more) letters, then it can match a string of letters and digits. Or it ignores the first (one or more) digits, then it can match a sequence of zero or more numbers; capital letters, ordinal letters (st, nd, rd), or time abbreviations (am or pm); or parts of decimal numbers. For the wildcard character:

  • It may sometimes serve as an alternative to regex (an advanced search covered later);
  • Wildcards work for word, phrase, and insource searches, but not in the intitle parameter.
  •  ? can represent one letter or number;

Or *? is also accepted, but ?* is not recognized.


  • For a word it means extra characters or changed characters.
  • For an phrase a fuzzy search requires a whole number telling how many extra words to fit in, but
  • for a word a fuzzy search is a decimal fraction, defaulting to word~0.5 (word~.5), where at most two letters can be found swapped, changed, or added, but never the first two letters.
  • For a word word~.1 is most fuzzy, and word~.9 is least fuzzy, and word~1 is not fuzzy at all.
"flowers algernon" Yes N N N
"flowers algernon"~0 Yes N N N
"flowers algernon"~1 Yes Yes N N
"flowers algernon"~2 Yes Yes Yes N
"flowers algernon"~11 Yes Yes Yes Yes
"algernon flowers"~1 N N N N
"algernon flowers"~2 Yes N N N
"algernon flowers"~3 Yes Yes N N
"algernon flowers"~4 Yes Yes Yes N
"algernon flowers"~13 Yes Yes Yes Yes

For the closeness value necessary to match in reverse (right to left) order, count and discard all the extra words, then add twice the the total count of remaining words minus one. (In other words, add twice the number of segments). For the full proximity algorithm, see Elastic Search. An explicit AND is required between two phrases because otherwise the two "inner" "quotation marks" are confused.


flowers flower Flowers for Algernon flower for Algernon
flowers Yes Yes Yes Yes Stemming is in effect.


Gerrit change 137733

Insource could be used to find any one word rendered on a page, but it's made for finding any odd phrase you might find including MediaWiki markup, and this phrase completely ignores greyspace: insource: "state state autocollapse" matches |state={{{state|autocollapse}}}.

insource: word
insource: "word1 word2"




Insource complements itself. On the one hand it has full text search for any word in the wikitext, instantly. On the other hand it can process a regexp search for any string of characters[8]. Regex scan all the textual characters in a given list of pages; they don't have a word index to speed things up, and the process is interrupted if it must run more than twenty seconds. Regex run last, so to limit needless character-level scanning, you advance it a list of pages (a search domain) selected by a indexed search added to the query as a "clause", and you do this to every single regex query.[9]. Insource can play both roles, and the best candidate for insource:/arg/ is often insource: arg, where arg is the same.



  • Both search wikitext only.
  • Neither finds things "sourced" by a transclusion.
  • Neither does stemmed, fuzzy, or proximity searches.

But indexed searches all ignore greyspace; wildcards searches do not match greyspace, so regex are the only way to find an exact string of any characters, for example a sequence of two spaces. Regex are an entirely different class of search tool that make matching a literal string in a regexp exact string search, a basic, easy search. Advanced regex are an entirely different endeavor than matching a literal string. See #Regular expression searches below.

The insource parameter treats words with embedded colons as one word. This effects searches for templates and parser functions, URLs, wikilinks, HTML tags, and comments.

Prefix and namespace[edit]

One namespace can be specified at the beginning of a search. Two or more namespaces may be set from the search results page, Special:Search, in the Advanced pane of the search bar. Furthermore, this search domain "profile" can be set and remembered as a user preference there.[11] Setting a namespace in the search box overrides all search bar settings or indications.</ref>

Enter a namespace name, or all. Enter a colon : for the default namespace. Namespace aliases are accepted.

When the the file namespace, is involved a namespace modifier local: has an effect, otherwise it is ignored.

file:Wind clock" Find pages in File locally and at Commons whose title, text, or media content contains the phrase "wind clock".
file:local:"Wind clock" Filter results from the file namespace of the Commons wiki.
local:"Wind clock" Ignored unless the file namespace is involved. "Local" must be lowercase.

You can now use an interwiki prefix as a namespace to search other projects.

The prefix syntax in its current form is relied upon for a great deal of functionality so it's been recreated as exactly as possible.


Find articles in the content namespaces whose title starts with the three letters c o w .

domestic prefix:cow


domestic prefix:cow/

Find all sub-pages of the article Cow in the content namespaces that contain the word "domestic". This is a very common search and is frequently built using a special URL parameter called prefix=.

domestic prefix:Talk:cow/

Find all sub-pages of the talk page of Cow, Talk:cow (in the talk namespace), that contain the word "domestic".

cow prefix:Pink Floyd/

Find all sub-pages of the article Pink Floyd in the content namespaces that contain the word "cow".

Note that the old rule of having to put prefix: at the end of the query still applies.

Prefix and namespace are used to set the initial search domain, but each is also a query. Like prefix, namespace can run alone, and it will return the the top twenty pages, and show the number of total pages.


Filters are required to accompany a bare regex search.

Any word or phrase is a filter because A filter returns a Y/N for every page in its given search domain. The filters If it can run as a standalone, a filter is also a query.

Intitle and incategory[edit]


  • cow*
  • intitle:foo
  • intitle:"fine line"
    • Find articles whose title contains fine then line. Stemming is disabled.
  • intitle:foo bar
  • -intitle:foo bar
  • intitle: foo bar
    • Syntax error, devolves into searching for articles whose title or text contains intitle:, foo, and bar.
  • incategory:Music
    • Find articles that are in Category:Music
  • incategory:"music history"
    • Find articles that are in Category:Music_history
  • incategory:"musicals" incategory:"1920"
    • Find articles that are in both Category:Musicals and Category:1920
  • incategory:Felis_silvestris_catus|Dogs
    • Find articles that are either in category:Felis_silvestris_catus or in Category:Dogs
  • -incategory:"musicals" incategory:"1920"

Intitle and incategory are old search parameters. Incategory no longer searches any subcategory automatically, but but you can now add multiple category pagenames manually. To get the search parameter deepcat, to automatically add up to 70 subcategories onto an incategory parameter, incategory:category1|category2|...|category70,  you can add a line to your user-customized javascript.[12]



Linksto does not find redirects. It only finds [[wikilinks]], not internal URL links. It does find wikilinks made by a template.


  1. linksto: "Help:Cirrus Search"
  2. linksto: Help:Searching
  3. linksto: H:S



You can specify template usage with hastemplate: template. Input the canonical pagename to find all usage of the template, but use any of its redirect pagenames finds just that naming. Namespace aliases are accepted, capitalization is entirely ignored, and redirects are found, all in one name-search. The namespace defaults to Template. (Compare boost-template no default namespace; linksto no namespace aliases, case-sensitive, no redirects; intitle no redirects.)

Hastemplate finds secondary (or meta-template) usage on a page: it searches the post-expansion inclusion. This is the same philosophy as for words and phrases from a template, but here it for templates from a template. The page will be listed as having that content even though that content is not seen in the wikitext.


Page weighting[edit]




  • morelike:wasp|bee|ant

Find articles about stinging insects.

  • morelike:template:search|template:regex|template:usage

Find templates about regex searching for template usage on the wiki.


  • cirrusMltMaxQueryTerms: Maximum number of terms to be considered.

These settings can be made persistent by overriding cirrussearch-morelikethis-settings in Help:System message.


You can give recently edited articles a boost in the search results.

  • prefer-recent: anywhere in the query.
  • prefer-recent:recent,boost

It goes anywhere in the query. It defaults to 160 days as recent. If you're interested in the last week, use 7 instead. All articles older than seven days are boosted half as much, and all articles older than 14 days are boosted half as much again, and so on. The boost is more than the usual multiplier, it is exponential. The factor used in the exponent is the time since the last edit.

and a score boost of 60% of the It takes a comma-separated pair of numbers defining "recent" and the boost. The default behavior for a bar adding "prefer-recent:" to the beginning of your search. By default this will scale 60% of the score exponentially with the time since the last edit, with a half life of 160 days. This can be modified like this: prefer-recent:proportion_of_score_to_scale,half_life_in_days

  • Proportion_of_score_to_scale must be a number between 0 and 1 inclusive.
  • Half_life_in_days must be greater than 0 but allows decimal points.

This number works pretty well if very small. I've tested it around .0001, which is 8.64 seconds.

This will eventually be on by default for Wikinews, but there is no reason why you can't activate it in any of your searches.


You can boost pages' scores based on what templates they contain. This can be done directly in the search via boost-templates:"" or you can set the default for all searches via the new cirrussearch-boost-templates message. boost-templates:"" replaces the contents of cirrussearch-boost-templates if the former is specified. The syntax is a bit funky but was chosen for simplicity. Some examples:

File:boost-templates:"Template:Quality Image|200%" incategory:china
Find files in the China category sorting quality images first.



Sorry for the inconsistent - in the name. Sorry again but the quotes are required on this one. Sorry also for the funky syntax. Sorry we don't try to emulate the template transclusion syntax like we do with hastemplate:.

Regular expression searches[edit]


because its possible that this could block other regexp searches. Other regex users are probably blocked when you query takes too long If ever a regexp search takes more than These return much much faster when you limit the regexp search-domain to the results of one or more index-based searches.

Warning: Do not run a bare insource:/regexp/ search. It will probably timeout after 20 seconds anyway, while blocking responsible users.


  • insource:"<tag>{{template}}<tag>" insource:/"<tag>{{template}}<\/tag>"/


[[ Special:Search/insource:/regex/ prefix:{{FULLPAGENAME}} | finds the term regex on this page ]].

Any search with no namespace specified (or prefix specified) searches your default search domain, settable on any search-results page, i.e. settable at Special:Search. The default search domain is commonly reset by power users to All namespaces, i.e. the entire wiki, but if this occurs for a bare regexp search, then on a large wiki it will probably incur an HTML timeout before completing the search.


  • intitle, incategory, and linksto are excellent filters.
  • hastemplate: is a very good filter.

The prefix operator is especially useful with a {{FULLPAGENAME}} in a search template, a search link, or an input box, because it automatically searches any subdirectories. To develop a new regexp, or refine a complex regexp, use prefix:{{FULLPAGENAME}} on a page with a sample of the target data.



This section covers how to escape the metacharacters used in rexexp searches. For the actual meaning of the metacharacters see the explanation of the syntax.[13]


For example,

  • to search a namespace, gague the number of pages with a single term that is a namespace. This will list the number of pages in that namespace.

Refining with an exact string.




  • You are obligated to supply an accompanying filter.
  • You must learn how to escape regex metacharacters.

There are two ways to escape metacharacters, and they are both useful at times, and sometimes concatenated side-by-side in the escaping of a string.

  • You can't mix methods, but you can concatenate them.


  • But /"This \" fails"/ always.


  • To match a / delimiter character use \/.
  • To match a " delimiter character use \".
  • The equivalent expression is "~@#&*()-+{}[]|\<>?.\".




For general examples using metacharacters


There are some notable differences from standard regex metacharacters:


Advanced example[edit]

For example, using metacharacters to find the usage of a template called Val having, inside the template call, an unnamed parameter containing a possibly signed, three to four digit number, possibly surrounded by space characters, AND on the same page, inside a template Val call, a named argument "fmt=commas" having any allowable spaces around it, (it could be the same template call, or a separate one):

hastemplate:val insource:"fmt commas" insource:/\{\{val\|[^}]*fmt *= *commas/ insource:/\{val\| *[-+]?[0-9]{3,4} *[|}]/

It is fast because it uses two filters so that every page the regexp crawls has the highest possible potential. Assuming your search domain is set to ALL, it searches the entire wiki, because it offers no namespace or prefix.

See also[edit]

External links[edit]

Notes and references[edit]

  1. During the migration period November 2013 to November 2014, &srbackend=CirrusSearch was secondary, and &srbackend=lsearchd (Extension:MWSearch) was primary. Both of these still available for use on the URL of a search results page.
  3. The highlighter is a yet another analyzer, in addition to the indexing analyzers. Being a large software application the Search highlighter may not always be 100% in sync (in the snippet) with what Search will match on the page. The highlighter can match better or worse. Nevertheless, query prefix:{{FULLPAGENAME}}. is certainly an excellent way to learn. For the most effective tests, search through just enough live pages to give a few hundred samples, by limiting the search domain with prefix.,
  5. CirrusSearch parameters do not use a consistent way to handle there search terms.
    • udp2log OR udp2log2
    • html2wt OR wt2html
    • log2ip OR ip2log
  8. CirrusSearch regex do not address the newline character directly, but dot . will match a newline.
  9. A wallowing regex search cannot disable Search, but can disable another's regex search.
  10. Cirrus search relaxed the prefix parameter syntax; now Search does allow a space here: prefix:string
  11. If you set a namespace profile as a user preference, the namespace selection dialog will present itself on future search results pages to inform you. To remove the dialog, select the default namespace (shown in parentheses), select "Remember", and press Search. Then remove all instances of &profile=advanced in the URL.
  12. In your global.js (or local, or skin) add
    mw.loader.load( "// Fischer (WMDE)/Gadgets/DeepCat.js&action=raw&ctype=text/javascript" );
    In your global.css (corresponding) add
    mw.loader.load( "// Fischer (WMDE)/Gadgets/DeepCat.css&action=raw&ctype=text/css" , "text/css" );
    See task T37402.
  13. For the formal definition see the Lucene grammar for regular expressions.