Help:CirrusSearch

CirrusSearch is a MediaWiki extension that uses es>w:Elasticsearch|Elasticsearch to provide enhanced search features over the helps>Help:Searching|default MediaWiki search. The Wikimedia Foundation uses CirrusSearch for all wmproj>m:Wikimedia_projects|Wikimedia projects.

This page describes the features of CirrusSearch.

If your question is not answered here, feel free to ask on the talk>Help talk:CirrusSearch|talk page and someone will answer it for you.

For information on the MediaWiki extension see extcc>Extension:CirrusSearch|Extension:CirrusSearch.

What's improved?
CirrusSearch features three main improvements over the default MediaWiki search, namely:


 * Better support for searching in different languages.


 * Faster updates to the search index, meaning changes to articles are reflected in search results much faster.


 * Expanding templates, meaning that all content from a template is now reflected in search results.

How frequently is the search index updated?
Updates to the search index are done in near real time.

Changes to pages should appear immediately in the search results.

Changes to templates should take effect in articles that include the template in a few minutes.

The templates changes use the job queue, so performance may vary.

A purge>Special:MyLanguage/Manual:Purge|null edit to the article will force the change through, but that shouldn't be required if everything is going well.

Search suggestions
The search suggestions you get when you type into the search box that drops down candidate pages is substantively the same with articles sorted by the number of incoming links.

Search suggestions can be skipped and queries will go directly to the search results page. Add a tilde "~" before the query. Example "~Frida Kahlo". The search suggestions will still appear, but hitting the Enter key at any time will take you to the search results page.

ASCII/accents/diacritics folding is turned on for English text, but there are some formatting problems with the result. See.

Full text search
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. Furthermore, for any changes in wording, the search index is updated within seconds. There are many indexes of the "full text" of the wiki to facilitate the many types of searches needed. The full wikitext is indexed many times into many special-purpose indexes, each parsing the wikitext in whatever way optimizes their use. Example indexes include
 * "auxiliary" text, includes hatnotes, captions, ToC, and any wikitext classed by an HTML attribute  class=searchaux .
 * "Lead-in" text is the wikitext between the top of the page and the first heading.
 * The "category" text indexes the listings at the bottom.
 * Templates are indexed. If the transcluded words of a template change, then all the pages that transclude it are updated. (This can take a long time depending on a job queue.) If the subtemplates used by a template change, the index is updated.
 * Document contents that are stored in the File/Media namespace are now indexed. Thousands of formats are recognized.

There is support for dozens of languages, but all languages are wanted.

There is a list of currently supported languages at [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html elasticsearch.org]; see their [http://www.elasticsearch.org/contributing-to-elasticsearch/ documentation on contributing] to submit requests or patches. CirrusSearch will optimize your query, and run it. The resulting titles are weighted by relevance, and heavily post-processed, 20 at a time, for the search results page. For example snippets are garnered from the article, and search terms are highlighted in bold text.

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

Search features also include:
 * sorting navigation suggestions by the number of incoming links.
 * Starting with the tilde character ~ to disable navigation and suggestions in such a way that also preserves page ranking.
 * Smart-matching characters by normalizing (or "folding") non-keyboard characters into keyboard characters.
 * Words and phrases that match are highlighted in bold on the search results page.

Words, phrases, and modifiers
The basic search term is a word or a "phrase in quotes". Search recognizes a "word" to be: A "stop word" is a word that is ignored (because it is common, or for other reasons). A given search term matches against content (rendered on the page). To match against wikitext instead, use the  insource  search parameter (See section below). Each search parameter has its own index, and interpret its given term in its own way.
 * a string of digits
 * a string of letters
 * subwords between letters/digit transitions, such as in  txt2regex 
 * subwords inside a compoundName using camel>w:CamelCase</>|camelCase

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 <tvar|grawlix> ~!@#$%^&*_+-={}|[]\:";'<>?,./ </>. A mixed string of greyspace characters and whitespace characters, is "greyspace", and is treated as one big word boundary. Greyspace is how indexes are made and queries are interpreted.

Two exceptions are where 1) an <tvar|ec>embedded:colon</> is one word (it being treated as a letter), and 2) an embedded comma, such as in <tvar|123> 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.

The modifiers are <tvar|mod> ~ * \? - " ! </>. Depending on their placement in the syntax they can apply to a term, a parameter, or to an entire query. Word and phrase modifiers are the wildcard, proximity, and fuzzy searches. Each parameter can have their own modifiers, but in general:
 * A fuzzy-word or fuzzy-phrase search can suffix a tilde ~ character (and a number telling the degree).
 * A tilde ~ character prefixing a query guarantees search results instead of any possible navigation.
 * A wildcard character inside a word can be a (escaped) question \? mark for one character or an asterisk * character for more.
 * Truth-logic can interpret <tvar|and> AND </> and <tvar|or> OR </>, but parameters cannot.
 * Truth-logic understands <tvar|dash> - </> or <tvar|exclaim> ! </> prefixed to a term to invert the usual meaning of the term from "match" to "exclude".
 * Quotes around words mark an "exact phrase" search. For parameters they are also needed to delimit multi-word input.
 * Stemming is automatic but can be turned off using an "exact phrase".

A phrase search can be initiated by various hints to the search engine. Each method of hinting has a side-effect of how tolerant the matching of the word sequence will be. For greyspvce, camelCase, or txt2number hints: A "search instead" report is triggered when a universally unknown word is ignored in a phrase.
 * given <tvar|wjgrey> words-joined_by_greyspace(characters) </> or <tvar|wjcamel> wordsJoinedByCamelCaseCharacters </> it finds <tvar|wjb> words joined by </> ... <tvar|char> characters </>, in their bare forms or greyspace forms.
 * <tvar|txt2n> txt2number </> will match <tvar|t2n> </> or <tvar|t2np> </>.
 * Stop words are enabled for the edge cases (in the periphery) of a grey_space or camelCase phrase. An example using <tvar|the> the </>, <tvar|of> of </>, and <tvar|a> a </> is that <tvar|ihoa> the_invisible_hand_of_a </> matches <tvar|mihs> </>.

Each one of the following types of phrase-matching contains and widens the match-tolerances of the previous one: A word search will "additionally" find the words anywhere on the page.
 * An "exact phrase" "in quotes" will tolerate (match with) greyspace. Given <tvar|exact_phrase> "exact_phrase" </> or <tvar|exactphrase> "exact phrase" </> it matches <tvar|exactbracket> </>.
 * A greyspace_phrase initiates stemming and stop word checks.
 * Given <tvar|camel> CamelCase </> it will additionally match <tvar|camelcase> </>, in all lowercase. CirrusSearch is case insensitive.

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

Note that all stemming is case insensitive.

Note how the "exact phrase" search interpreted the <tvar|ec>embedded:colon</> character as a letter, but not the embedded_underscore character. A similar event occurs with the comma, character inside a number.

Given <tvar|inthisword> </>, CirrusSearch, when in an "exact phrase" context, (which includes the insource parameter context), will not match <tvar|in> </>, <tvar|this> </>, or <tvar|word> </>, but will then only match <tvar|inthiswordcolon> </>.

Otherwise, remember that for CirrusSearch words are letters, numbers, or a combination of the two, and case does not matter.

The common word search employs the space character and is aggressive with stemming, and when the same words are joined by greyspace characters or camelCase they are aggressive with phrases and subwords.

When common words like "of" or "the" are included in a greyspace-phrase, they are ignored, so as to match more aggressively.

A greyspace_phrase search term, or a camelCase, or a txt2number term, match the signified words interchangeably. You can use any of those three forms. Now <tvar|camelcase> camelcase </> matches <tvar|camelCase> camelCase </> because Search is not case sensitive, but <tvar|camelCase2> camelCase </> matches <tvar|camelcase2> camelcase </> because camelCase is more aggressive. Like the rest of Search, subword "words" are not case-sensitive. By comparison the "exact phrase" is greyspace oriented and ignores numeric or letter-case transitions, and stemming. "Quoted phrases" are not case sensitive.

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

Making inquiries with numbers, we would find that The star <tvar|asterisk> * </> wildcard matches a string of letters and digits within a rendered word, but never the beginning character. One or more characters, a percentage of the word, must precede the <tvar|asterisk> * </> character. The <tvar|quest> \? </> wildcard represents one letter or number; The <tvar|bsq> *\? </> is also accepted, but <tvar|bsqast> \?* </> is not recognized.
 * <tvar|Plan9> Plan9 </> or <tvar|Plan_9> Plan_9 </> matches any of: <tvar|plan9> </>, <tvar|plans9> </>, <tvar|planned9th> </>, <tvar|planned92> </>, <tvar|plans> </>
 * <tvar|plan92> "plan9" </> only matches <tvar|plan93> </> (case insensitive)
 * <tvar|planast> Plan*9 </> matches <tvar|plan94> </> or <tvar|planet> </>.
 * If the leading part is only letters then it will limit a match to a string of (zero of more) letters.
 * If only numbers, then it will limit a match to a sequence of (zero or more) numbers, including also ordinal letters (st, nd, rd), capital letters, or time abbreviations (am or pm); and it will match the entirety of (both sides of) a decimal numbers.
 * Otherwise the comma is considered part of one number, but the decimal point is considered a greyspace character, and will delimit two numbers.
 * Inside an "exact phrase" it matches stemming plus compounding.

The wildcards are for basic word, phrase, and insource searches, and may also be an alternative to (some) advanced regex searches (covered later).

Putting a tilde <tvar|tilde> ~ </> character after a word or phrase activates a fuzzy search.
 * For a phrase it is termed a proximity search, because proximal words are tolerated to an approximate rather than exact phrase.
 * For example, <tvar|exact12p> "exact one two phrase"~2 </> matches <tvar|exact>.
 * For a word it means extra characters or changed characters.
 * For a phrase a fuzzy search requires a whole number telling it how many extra words to fit in, but for a word a fuzzy search can have a decimal fraction, defaulting to <tvar|word05> word~0.5 </> (<tvar|wordtilde> word~.5 </>), where at most two letters can be found swapped, changed, or added, but never the first two letters.
 * For a proximity phrase, a large number can be used, but that is an "expensive" (slow) search.
 * For a word <tvar|wordtilde1> word~.1 </> is most fuzzy, and <tvar|wordtilde9> word~.9 </> is least fuzzy, and <tvar|wordtilde12> word~1 </> is not fuzzy at all.

For the closeness value necessary to match in reverse (right to left) order, count and discard all the extra words, then add twice the total count of remaining words minus one. (In other words, add twice the number of segments). For the full proximity algorithm, see [<tvar|esslop>https://www.elastic.co/guide/en/elasticsearch/guide/current/slop.html</> Elasticsearch slop]. An explicit AND is required between two phrases because otherwise the two "inner" "quotation marks" are confused.

Quotes turn off stemming, <tvar|appendtilde> "but appending"~ </> the tilde reactivates the stemming.

Insource
Insource searches can be used to find any one word rendered on a page, but it's made for finding any phrase you might find - including MediaWiki markup. This phrase completely ignores greyspace: <tvar|issa> insource: "state state autocollapse" </> matches <tvar|state> </>. 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. 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 an indexed search added to the query as a "clause", and you do this to every single regex query. . Insource can play both roles, and the best candidate for <tvar|insourcearg> insource:/arg/ </> is often <tvar|insourcearg2> insource: arg </>, where arg is the same.

The syntax for the regexp is <tvar|insource> insource: </> no space, and then <tvar|regexp> /regexp/ </>. (No other parameter disallows a space. All the parameters except <tvar|regex> insource:/regexp/ </> generously accept space after their colon. )

Insource indexed-search and regexp-search roles are similar in many respects: 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 regexanchor>#Regular expression searches</> below.
 * Both search wikitext only.
 * Neither finds things "sourced" by a transclusion>Special:MyLanguage/Help:Transclusion</>|transclusion.
 * Neither does stemmed, fuzzy, or proximity searches.
 * Both want the fewest results, and both work faster when accompanied by another clause.

Prefix and namespace
One namespace can be specified at the beginning of a search. Two or more namespaces may be set from the search results page, spsearch>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. Setting a namespace in the search box overrides all search bar settings or indications.

Enter a namespace name, or enter <tvar|all> </>, or enter a colon  <tvar|colon> </>  for mainspace.

Namespace aliases are accepted. When the the file namespace, is involved a namespace modifier <tvar|local> </> has an effect, otherwise it is ignored. You can now use an interwiki prefix as a namespace to search other projects.

The <tvar|prefixcolon> prefix: </> syntax in its current form is relied upon for a great deal of functionality so it's been recreated as exactly as possible.

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
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 can run as a standalone, a filter is also a query.

Intitle and incategory
Word and phrase searches match in a title and match in the category box on bottom of the page. But with these parameters you can select titles only or category only.


 * <tvar|cowast> cow* </>
 * Find articles whose title or text contains words that start with cow


 * <tvar|itfoo> intitle:foo </>
 * Find articles whose title contains foo. Stemming is enabled for foo.
 * <tvar|itfineline> intitle:"fine line" </>
 * Find articles whose title contains fine line. Stemming is disabled.
 * <tvar|itfoobar> intitle:foo bar </>
 * Find articles whose title contains foo and whose title or text contains bar.
 * <tvar|itfoo_bar> -intitle:foo bar </>


 * Find articles whose title does not contain foo and whose title or text contains bar.
 * <tvar|icmusic> incategory:Music </>
 * Find articles that are in Category:Music
 * <tvar|icmusichistory> incategory:"music history" </>
 * Find articles that are in Category:Music_history

Intitle and incategory are old search parameters. Incategory no longer searches any subcategory automatically, but you can now add multiple category pagenames manually. To get the search parameter [//wikitech.wikimedia.org/wiki/Nova_Resource:Catgraph/Deepcat deepcat], to automatically add up to 70 subcategories onto an incategory parameter, <tvar|incategory> incategory:category1|category2|...|category70 </>, you can add a line to your user-customized javascript.
 * <tvar|icmusicals> incategory:"musicals" incategory:"1920" </>
 * Find articles that are in both Category:Musicals and Category:1920
 * <tvar|icmusicalsnot> -incategory:"musicals" incategory:"1920" </>
 * Find articles that are not in Category:Musicals but are in Category:1920

Linksto
Linksto finds wikilinks to a given name, not links to content. The input is the canonical, case sensitive, page name. It must match the title line of the content page, exactly, before any title modifications of the letter-case. (It must match its { {FULLPAGENAME}}, e.g. .)

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

To find all wikilinks to a "<tvar|hcs>Help:Cirrus Search</>", if "<tvar|helpSearching>Help:Searching</>" and "<tvar|HS>H:S</>" are redirects to it:

<tvar|linksto1># linksto: "Help:Cirrus Search"</> <tvar|linksto2># linksto: Help:Searching</> <tvar|linksto3># linksto: H:S</>

<tvar|linksto> </> finds articles that mention "<tvar|CirrusSearch>CirrusSearch</>" but not in a wikilink.

Hastemplate
You can specify template usage with <tvar|hastemplate> </>. 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's for templates from a template. The page will be listed as having that content even though that content is not seen in the wikitext.


 * <tvar|hastempquality> hastemplate: "quality image" </>, finds "<tvar|tempquality>Template:Quality image</>" usage in your default search domain (namespaces).
 * <tvar|hastportal> : hastemplate: portal:contents/tocnavbar </>, finds mainspace usage of a "<tvar|tocnavbar>Contents/TOCnavbar</>" template in the Portal namespace.

Page weighting
Weighting determines snippet, suggestions, and page relevance. The normal weight is one. Additional weighting is given through multipliers.

If the query is just words, pages that match them in order are given a boost. If you add any explicit phrases to your search, or for certain other additions, this "prefer phrase" feature is not applied.

Morelike
Find articles about stinging insects. Find templates about regex searching for template usage on the wiki.
 * <tvar|morelike> morelike:page name 1|page name 2|...|page name n </>
 * Find articles whose text is most similar to the text of the given articles.
 * <tvar|mlbugs> morelike:wasp|bee|ant </>
 * <tvar|mltemplate> morelike:template:search|template:regex|template:usage </>

The <tvar|morelike> morelike: </> query works by choosing a set of words in the input articles and run a query with the chosen words. You can tune the way it works by adding the following parameters to the search results URL: These settings can be made persistent by overriding <tvar|cirrusmlt> </> in hlpsysmsg>Special:MyLanguage/Help:System message</>.
 * <tvar|cmmindf> cirrusMltMinDocFreq </>: Minimum number of documents (per shard) that need a term for it to be considered.
 * <tvar|cmmaxdf> cirrusMltMaxDocFreq </>: Maximum number of documents (per shard) that have a term for it to be considered.
 * <tvar|cmmaxqt> cirrusMltMaxQueryTerms </>: Maximum number of terms to be considered.
 * <tvar|cmmintf> cirrusMltMinTermFreq </>: Minimum number of times the term appears in the input to doc to be considered. For small fields (<tvar|title> title </>) this value should be 1.
 * <tvar|cmminwl> cirrusMltMinWordLength </>: Minimal length of a term to be considered. Defaults to 0.
 * <tvar|cmmaxwl> cirrusMltMaxWordLength </>: The maximum word length above which words will be ignored. Defaults to unbounded (0).
 * <tvar|cmf> cirrusMltFields </> (comma separated list of values): These are the fields to use. Allowed fields are <tvar|title> title </>, <tvar|text> text </>, <tvar|auxtext> auxiliary_text </>, <tvar|opening> opening_text </>, <tvar|headings> headings </> and <tvar|all> all </>.
 * <tvar|cmuf> cirrusMltUseFields </> (<tvar|true> </>|<tvar|false> </>): use only the field data. Defaults to <tvar|false2> </>: the system will extract the content of the <tvar|text2> </> field to build the query.
 * <tvar|cmpttm> cirrusMltPercentTermsToMatch </>: The percentage of terms to match on. Defaults to 0.3 (30 percent).
 * Example: <tvar|cmufcode> </>

Prefer-recent
You can give recently edited articles a boost in the search results.
 * <tvar|pr> prefer-recent: </> anywhere in the query.
 * <tvar|pr-boost> prefer-recent:recent,boost </>

<tvar|pr2> prefer-recent: </> 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.

It takes a comma-separated pair of numbers defining "recent" and the boost. The default behavior for a bar adding "<tvar|pr3>prefer-recent:</>" to the beginning of your search. By default this will scale 60% of the score exd>w:Exponential_decay</>|exponentially with the time since the last edit, with a half life of 160 days. This can be modified like this: <tvar|prexample> 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.

The Half_life_in_days number works 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.

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


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


 * <tvar|fbtlow> File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" incategory:china </>
 * Find files in the China category sorting quality images first and low quality images last.


 * <tvar|tqpop> File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" popcorn </>
 * Find files about popcorn sorting quality images first and low quality images last. Remember that through the use of the <tvar|sbt1> </> message this can be reduced to just <tvar|popcorn> </>.

Don't try to add decimal points to the percentages. They don't work and search scoring is such that they are unlikely to matter much.

A word of warning about <tvar|csbt> </>: if you add really really big or small percentages they can poison the full text scoring. Think, for example, if enwiki boosted featured articles by a million percent. Then searches for terms mentioned in featured articles would find the featured articles before exact title matches of the terms. Phrase matching would be similarly blown away so a search like <tvar|bnw> </> would find a featured article with those words scattered throughout it instead of the article for bnw>w:Brave New World</>|Brave New World.

Regular expression searches
A basic indexed-search finds words rendered visible on a page. Hyphenation and punctuation marks and bracketing, slash and other math and computing symbols, are merely boundaries for the words. It is not possible to include them in an indexed search.

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 <tvar|insreg> insource:/regexp/ </> search. It will probably timeout after 20 seconds anyway, while blocking responsible users.

An "exact string" regexp search is a basic search; it will simply "quote" the entire regexp, or "backslash-escape" all non-alphanumeric characters in the string. All regexp searches also require that the user develop a simple filter to generate the search domain for the regex engine to search:
 * <tvar|isdebian> insource:"debian.reproducible.net" insource: / debian\.reproducible\.net /  </>
 * <tvar|isprogram> insource:"c:\program files (x86)" insource: / C\:\\Program Files \(x86\) /i  </>
 * <tvar|istemplate> insource:"<tag>{ {template}}<tag>" insource: / "<tag>{ {template}}<\/tag>" / </>
 * <tvar|islink> insource:"[ [title|link label]]'s" insource: / "[ [title|link label]]'s" / </>
 * <tvar|isfullpage> insource: / regexp / prefix:{ {FULLPAGENAME}} </>

The last example works from a link on a page, but { {FULLPAGENAME}} doesn't function in the search box. For example
 * ' [[Special:Search/insource:/regex/ prefix:| 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 ss>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.

A regex search actually scours each page in the search domain character-by character. By contrast, an indexed search actually queries a few records from a database separately maintained from the wiki database, and provides nearly instant results. So when using using an insource:// (a regexp of any kind), consider creating one the other search terms that will limit the regex search domain as much as possible. There are many search terms that use an index and so instantly provide a more refined search domain for the /regexp/. In order of general effectiveness: The prefix operator is especially useful with a { {FULLPAGENAME}} in a search template, a search link, or an extib>Extension:InputBox|input box</>, because it automatically searches any subdirectories. To develop a new regexp, or refine a complex regexp, use <tvar|fpn> </> on a page with a sample of the target data.
 * insource:"" with quotation marks, duplicating the regexp except without the slashes or escape characters, is ideal.
 * intitle, incategory, and linksto are excellent filters.
 * hastemplate: is a very good filter.
 * "word1 word2 word3", with or without the quotation marks, are good.
 * namespace: is practically useless, but may enable a slow regexp search to complete.

Search terms that do not increase the efficiency of a regexp search are the page-scoring operators: morelike, boost-template, and prefer-recent.

Metacharacters
This section covers how to escape metacharacters used in rexexp searches

For the actual meaning of the metacharacters see the [<tvar|link1>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax</> explanation of the syntax].

For example: Refining with an exact string. You can start out intending an exact string search, but keep in mind: There are two ways to escape metacharacters. They are both useful at times, and sometimes concatenated side-by-side in the escaping of a string. Double-quotes escaping using insource:/"regexp"/ is an easy way to search for many kinds of strings, but you can't backslash-escape anything inside a double-quoted escape. Backslash-escape using insource:/regexp/ allows escaping the " and / delimiters, but requires taking into account metacharacters, and escaping any: The simplest algorithm to create the basic string-finding expression using insource:/"regexp"/, need not take metacharacters into account except for the " and / characters:
 * to search a namespace, gauge the number of pages with a single term that is a namespace. This will list the number of pages in that namespace.
 * starting out to find again what you may have seen, like "wiki-link" or "(trans[in]clusion)" start with namespace and insource filters.
 * refinining an ongoing search process with what you want to see, like "2 + 2 = 4", or "site.org" This is ideally the best use of regex, because it adds it as a single regexp term while refining a search, the limited number of pages the regexp must crawl is can be seen.
 * regex only search the wikitext not the rendered text, so there are some differences around the markup, and even the number of space characters must match precisely.
 * You are obligated to supply an accompanying filter.
 * You must learn how to escape regex metacharacters.
 * Backslash-escape one of them \char. The insource:/regexp/ uses slashes to delimit the regexp. Giving /reg/exp/ is ambiguous, so you must write /reg\/exp/.
 * Put a string of them in double quotes "string". Because escaping a character can't hurt, you can escape any character along with any possible metacharacters in there. Escaping with quotes is cleaner.
 * You can't mix methods, but you can concatenate them.
 * <tvar|pntemp> </> instead of <tvar|pntemp-late> </>
 * <tvar|literal> </> is as good as <tvar|literal2> </>
 * But <tvar|thisfails> </> always.
 * And <tvar|thisdepends> </>. It finds the <tvar|vvv> </> literally, which is not the <tvar|slash> </> you probably wanted.
 * To match a <tvar|slash2> </> delimiter character use <tvar|vvv2> </>.
 * To match a <tvar|quote> </> delimiter character use <tvar|slashquote> </>.
 * The metacharacters would be <tvar|grawlix2> </>.
 * The equivalent expression is <tvar|grawlix3> </>.
 * 1) Write <tvar|str_ing> </> out. (The /" delimiters "/ are not shown.)
 * 2) Replace <tvar|doublequote> </> with <tvar|slashdoublequote> </> (previous double-quote: stop, concatenate, quote restart).
 * 3) Replace <tvar|slash4> </> with <tvar|vvv3> </> (stop, concatenate, start).
 * 4) You get <tvar|insource> </>, showing concatenation of the two methods.

The square-bracket notation for creating your own character-class also escapes its metacharacters. To target a literal right square bracket in your character-class pattern, it must be backslash escaped, otherwise it can be interpreted as the closing delimiter of the character-class pattern definition. The first position of a character class will also escape the right square bracket. Inside the delimiting square brackets of a character class, the dash character also has special meaning (range) but it too can be included literally in the class the same way as the right square bracket can. For example both of these patterns target a character that is either a dash or a right square bracket or a dot: <tvar|code1> </> or <tvar|code2> </>.

For general examples using metacharacters: There are some notable differences from standard regex metacharacters:
 * <tvar|insource0> insource:"2+2=4" insource:/"2+2=4"/ </> matches "2 + 2 = 4", with zero spaces between the characters.
 * <tvar|insource01> insource:"2 + 2 = 4" insource:/2 ?\+ ?2 ?= ?4\./ </> match with zero or one space in between. The equals = sign is not a metacharacter, but the plus + sign is.
 * <tvar|insourcetag> insource:"<tag>[ [link|2\3?]]\</tag>" insource:/"<tag>[ [link|2\3?]]< "\/" tag>"/ </>.
 * The dot . metacharacter stands for any character including a newline, so .* matches across lines.
 * The number # sign means something, and must be escaped.
 * The ^ and $ are not needed. Like "grep" (global per line, regular expression, print each line), each insource:// is a "global per document, regular expression, search-results-list each document" per document.
 * support a multi-digit numeric range like [0-9] does, but without regard to the number of character positions, or the range in each position, so <9-10> works, and even <1-111> works.

Advanced example
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<tvar|fmtcomma> </> having any allowable spaces around it, (it could be the same template call, or a separate one):

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.

bounded
You can limit search to pages identified as being near some specified geographic coordinates. The coordinates can either be specified as a, pair, or by providing a page title from which to source the coordinates. A distance to limit the search to can be prepended if desired. Examples:


 * <tvar|ntSF> neartitle:"San Francisco" </>
 * <tvar|ntSFkm> neartitle:"100km,San Francisco" </>
 * <tvar|ncll> nearcoord:37.77666667,-122.39 </>
 * <tvar|ncllkm> nearcoord:42km,37.77666667,-122.39 </>

boosted
You can alternatively increase the score of pages within a specified geographic area. The syntax is the same as bounded search, but with boost- prepended to the keyword. This effectively doubles the score for pages within the search range, giving a better chance for nearby search results to be near the top.


 * <tvar|bntSF> boost-neartitle:"San Francisco" </>
 * <tvar|bntSFkm> boost-neartitle:"100km,San Francisco" </>
 * <tvar|bncll> boost-nearcoord:37.77666667,-122.39 </>
 * <tvar|bncllkm> boost-nearcoord:42km,37.77666667,-122.39 </>

File properties search
Since MediaWiki 1.28, CirrusSearch supports indexing and searching of properties of files in the <tvar|file> </> namespace. This includes:
 * file media type
 * MIME type
 * size
 * width & height
 * resolution
 * bit depth for files that support these

filetype
Searching for file type allows to retrieve files according to their classification, such as office documents, videos, raster images, vector images, etc. The following types currently exist:
 * <tvar|UNKNOWN> </>
 * <tvar|BITMAP> </>
 * <tvar|DRAWING> </>
 * <tvar|AUDIO> </>
 * <tvar|VIDEO> </>
 * <tvar|MULTIMEDIA> </>
 * <tvar|OFFICE> </>
 * <tvar|TEXT> </>
 * <tvar|EXECUTABLE> </>
 * <tvar|ARCHIVE> </>

This list may be extended in the future. See also <tvar|mediatype> </> constants in <tvar|defines> </>.

The syntax of the search is: <tvar|filetype> filetype:{type} </>. Example:

<tvar|ftvideo> filetype:video </> - looks for all videos

The filetype search is not case-sensitive.

filemime
Matches file MIME type. The syntax is:

<tvar|filemime> filemime:{MIMEtype} </> - look for files of this MIME type

The argument can be quoted to specify exact match. Without quotes, partial matches to components of MIME type will be accepted too.

Examples:

<tvar|fmimg> filemime:"image/png" </> - look for files with MIME type exactly <tvar|imgpng> </>

<tvar|fnpdf> filemime:pdf </> - look for all PDF documents

The MIME type search is not case sensitive.

filesize
Search for file of given size, in kilobytes (kilobyte means 1024 bytes). The syntax is:

<tvar|fsnum> filesize:{number} </> or <tvar|fsgreater> filesize:>{number} </> - file with size at least given number

<tvar|fsless> filesize:<{number} </> - file with size no more than given number

<tvar|fsbetween> filesize:{number},{number} </> - file with size between given numbers

Examples:

<tvar|fs20> filesize:>20 </> or <tvar|fseq20> filesize:20 </> - files 20Kb and bigger

<tvar|fsless1024> filesize:<1024 </> - files smaller than 1Mb

<tvar|fs100k> filesize:100,500 </> - files with sizes between 100kb and 500kb

File measures
It is possible to search for specific file measures: width, height and resolution, which is defined as square root of height, width, and bit depth. Not all files may have these properties. The syntax is:

<tvar|mn> {measure}:{number} </> - file with measure that equals to given number

<tvar|mng> {measure}:>{number} </> - file with measure that is at least given number

<tvar|mnl> {measure}:<{number} </> - file with measure that is no more than given number

<tvar|mnn> {measure}:{number},{number} </> - file with measure that is between given numbers

Where <tvar|measure> </> can be:

<tvar|filew1> filew </> or <tvar|filew2> filewidth </> - file widh

<tvar|fileh1> fileh </> or <tvar|fileh2> fileheight </> - file height

<tvar|fres> fileres </> - file resolution (see above)

<tvar|fbd> filebits </> - file bit depth

Examples:

<tvar|fw800> filew:>800 fileh:>600 </> - files that are bigger than 800x600

<tvar|fb16> filebits:16 </> - files with 16-bit color depth

<tvar|fh100k> fileheight:100,500 </> - file between 100 and 500 pixels high