Render: Difference between revisions

Find traditional instrumental music
No edit summary
(Blanked the page)
Tag: Blanking
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<!--T:413-->
The quickest way to find information in the Traditional Tune Archive is to look it up directly. On every page there is a '''search''' box.


<!--T:1-->
'''CirrusSearch''' is a Traditional Tune Archive extension that uses Elasticsearch to provide enhanced search features over the default TTA search. The Wikimedia Foundation uses CirrusSearch for all Wikimedia projects.
<!--T:66-->
This page describes the features of CirrusSearch.
<!--T:3-->
<!--T:174-->
== How it works ==
<!--T:414-->
<!--T:415-->
Enter key words and phrases and press ''Enter'' or ''Return'' on your keyboard. Or click the magnifying glass icon, Search, or Go button.
<!--T:416-->
If a Tune has the same title as what you entered you will be directed to that page.
<!--T:417-->
Otherwise, it searches all pages on the wiki, and presents a list of articles that matched your search terms, or a message informing you that no page has all the key words and phrases.
<!--T:418-->
If you click the search button without filling in anything, you will be taken to "Special:Search" which gives you extra searching options (also available from any search results list)
<!--T:419-->
You may find it useful to restrict a search to pages within a particular namespace e.g., only search within the Book pages.
<!--T:420-->
Check the namespaces you require for this search.
<!--T:421-->
By default only the namespaces specified in your preferences will be searched.
<!--T:422-->
Logged-in users can change their preferences to specify the namespaces they want to search by default.
<!--T:423-->
This can be done by selecting and deselecting boxes in the ”search” section of user preferences.
<!--T:466-->
Adding additional default namespaces has a side effect of changing the autocomplete algorithm from the default to a somewhat stricter algorithm.
== What's improved? ==
<!--T:5-->
CirrusSearch features three main improvements over the default MediaWiki search, namely:
<!--T:6-->
* Better support for searching in different languages.
<!--T:7-->
* Faster updates to the search index, meaning changes to articles are reflected in search results much faster.
<!--T:8-->
* Expanding templates, meaning that all content from a template is now reflected in search results.
== How frequently is the search index updated? == <!--T:9-->
<!--T:10-->
Updates to the search index are done in near real time.
<!--T:67-->
Changes to pages should appear immediately in the search results.
<!--T:68-->
Changes to templates should take effect in articles that include the template in a few minutes.
<!--T:69-->
The templates changes use the job queue, so performance may vary.
<!--T:70-->
A null edit to the article will force the change through, but that shouldn't be required if everything is going well.
== Search suggestions == <!--T:11-->
<!--T:12-->
The search suggestions you get when you type into the search box that drops down candidate pages is sorted by a rough measure of article quality.
<!--T:371-->
This takes into account the number of incoming wikilinks, the size of the page, the number of external links, the number of headings, and the number of redirects.
<!--T:71-->
Search suggestions can be skipped and queries will go directly to the search results page. Add a tilde <code>~</code> before the query. Example "~Jackie Layton". The search suggestions will still appear, but hitting the Enter key at any time will take you to the search results page.
<!--T:13-->
ASCII/accents/diacritics folding is turned on for English text, but there are some formatting problems with the result.
== Full text search == <!--T:14-->
<!--T:15-->
A "full text search" is an "indexed search". All pages are stored in the wiki database, and all the words in the non-redirect pages are stored in the search database, which is an index to practically 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.
<!--T:427-->
Note that the tagline is not part of the actual content. To see the searchable content for a page append ?action=cirrusdump to the URL.
<!--T:428-->
Furthermore, for any changes in wording, the search index is updated within seconds.
<!--T:175-->
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:
<!--T:176-->
* "auxiliary" text, includes hatnotes, captions, ToC, and any wikitext classed by an HTML attribute.
* "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.
<!--T:78-->
There is support for dozens of languages, but all languages are wanted.
<!--T:81-->
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.
<!--T:177-->
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.
<!--T:178-->
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).
<!--T:179-->
Search features also include:
<!--T:180-->
* 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.
<!--T:181-->
* Words and phrases that match are highlighted in bold on the search results page. The highlighter is a cosmetic analyzer, while the search-indexing analyzer actually finds the page, and these may not be 100% in sync, especially for regex.  The highlighter can match more or less accurately than the indexer.
=== Words, phrases, and modifiers === <!--T:182-->
<!--T:183-->
The basic search term is a word or a "phrase in quotes". Search recognizes a "word" to be:
<!--T:184-->
* a string of digits
* a string of letters
* subwords between letters/digit transitions, such as in txt2regex
* subwords inside a compoundName using camelCase
<!--T:185-->
A "stop word" is a word that is ignored (because it is common, or for other reasons).<!--T:429--> Stop words are rarely called for in CirrusSearch, except for when they are in certain kinds of phrases, as explained below.
<!--T:186-->
A given search term matches against ''content'' (rendered on the page). To match against wikitext instead, use the insource search parameter (See [[#Insource|section]] below). Each search parameter has its own index, and interpret its given term in its own way.<!--T:430--> CirrusSearch parameters do not use a consistent way to handle these search terms.
<!--T:187-->
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 <code>~!@#$%^&*()_+-={}|[]\:";'<>?,./</code>. 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.<!--T:431--> [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html The same analyzer] used to index the wikitext is also used to interpret the query.
<!--T:188-->
Two exceptions are where 1) an embedded<code>:</code>colon is one word (it being treated as a letter), and 2) an embedded comma <code>,</code> such as in <code>1,2,3</code>,  is treated as a number.
Greyspace characters are otherwise ignored unless, due to query syntax, they can be interpreted as modifier characters.
<!--T:189-->
The modifiers are <tvar|mod><kbd>~ * \? - " ! </kbd></>. 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:
<!--T:190-->
* A fuzzy-word or fuzzy-phrase search can suffix a tilde <tvar|tilde><code>~</code></> character (and a number telling the degree).
* A tilde <tvar|tilde><code>~</code></> character prefixed to the first term of 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 <tvar|asterisk><kbd>*</kbd></> character for more.
* Truth-logic can interpret <tvar|and><kbd>AND</kbd></> and <tvar|or><kbd>OR</kbd></>, but parameters cannot.
* Truth-logic understands <tvar|dash><kbd>-</kbd></> or <tvar|exclaim><kbd>!</kbd></> prefixed to a term to invert the usual meaning of the term from "match" to "exclude".
Words that begin with -  or !, such as -in-law or !Kung can exactly match titles and redirects, but will also match every document that does ''not'' contain the negated word, which is usually almost all documents. To search for such terms other than as exact matches for titles or redirects, use the insource search parameter.
* 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".
</translate>
{{tip|1=<translate><!--T:191--> The two wildcard characters are the star and the (escaped) question mark, and both can come in the middle or end of a word. The escaped question mark <tvar|quest><kbd>\?</kbd></> stands for one character and the star <tvar|asterisk><kbd>*</kbd></> stands for any number of characters. Because many users, instead of writing a query, will ask a question, any question mark is ignored unless purposefully escaped <tvar|quest><kbd>\?</kbd></> into its wildcard meaning.</translate>}}
<translate>
<!--T:192-->
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 ''greyspace'', ''camelCase'', or ''txt2number'' hints:
</translate>
<translate>
<!--T:193-->
* given <tvar|wjgrey><kbd>words-joined_by_greyspace(characters)</kbd></> or <tvar|wjcamel><kbd>wordsJoinedByCamelCaseCharacters</kbd></> it finds <tvar|wjb><kbd>words joined by</kbd></> ... <tvar|char><kbd>characters</kbd></>, in their bare forms or greyspace forms.
* <tvar|txt2n><kbd>txt2number</kbd></> will match <tvar|t2n><code>txt 2 number</code></> or <tvar|t2np><code>txt-2.number</code></>.
* Stop words are enabled for the edge cases (in the periphery) of a grey_space or camelCase phrase. An example using <tvar|the><kbd>the</kbd></>, <tvar|of><kbd>of</kbd></>, and <tvar|a><kbd>a</kbd></> is that <tvar|ihoa><kbd>the_invisible_hand_of_a</kbd></> matches <tvar|mihs><code>meetings invisible hand shake</code></>.
</translate>
<translate>
<!--T:194-->
A "search instead" report is triggered when a universally unknown word is ignored in a phrase.
<!--T:195-->
Each one of the following types of phrase-matching contains and widens the match-tolerances of the previous one: 
</translate>
<translate>
<!--T:196-->
* An "exact phrase" "in quotes" will tolerate (match with) greyspace. Given <tvar|exact_phrase><kbd>"exact_phrase"</kbd></> or <tvar|exactphrase><kbd>"exact phrase"</kbd></> it matches <tvar|exactbracket><code>"exact]phrase"</code></>.
* A greyspace_phrase initiates stemming and ''stop word'' checks.
* Given <tvar|camel><kbd>CamelCase</kbd></> it will ''additionally'' match <tvar|camelcase><code>camelcase</code></>, in all lowercase, because CirrusSearch is not case sensitive in matching.
<!--T:424-->
Page ranking saves you from typing quotes for a two-word search. With no quotes a word-pair index is used in page-ranking, plus it finds the two words anywhere on the page. 
<!--T:198-->
Some parameters interpret greyspace phrases, but other parameters, like <tvar|insource><code>insource</code></> only interpret the usual "phrase in quotes".
</translate>
{{tip|1=<translate><!--T:199--> In search terminology, support for "stemming" means that a search for "swim" will also include "swimming" and "swimmed", but not "swam".</translate>}}
{| class=wikitable
!Search phrase
!        parserfunction !! parserFunction !! parser function !! parser-function !! parser:function !! parSer:funcTion
|-
| parserfunction || {{check}} || {{check}} || {{cross}} || {{cross}} || {{cross}} || {{cross}}
|-
| "parser function" || {{cross}} || {{cross}} || {{check}} || {{check}} || {{cross}} || {{cross}}
|-
| parser_function || {{cross}} || {{check}} || {{check}} || {{check}} || {{cross}} || {{cross}}
|-
| parserFunction || {{check}} || {{check}} || {{check}} || {{check}} || {{cross}} || {{cross}}
|-
| "parser:function" || {{cross}} || {{cross}} || {{cross}} || {{cross}} || {{check}} || {{check}}
|-
| "parser_function" || {{cross}} || {{cross}} || {{check}} || {{check}} || {{cross}} || {{cross}}
|-
| "parSer_funcTion" || {{cross}} || {{cross}} || {{check}} || {{check}} || {{cross}} || {{cross}}
|-
| parSer_FuncTion || {{cross}} || {{cross}} || {{check}} || {{check}} || {{check}} || {{check}}
|}
<!--T:201-->
Note that all stemming is case insensitive.
<translate>
<!--T:202-->
Note how the "exact phrase" search interpreted the <kbd>embedded:colon</kbd> character as a letter, but not the <kbd>embedded_underscore</kbd> character. A similar event occurs with the comma <tvar|comma><kbd>,</kbd></> character inside a number.
<!--T:203-->
Given <tvar|inthisword><code>in:this:word</code></>, CirrusSearch, when in an "exact phrase" context, (which includes the ''insource'' parameter context), will not match <tvar|in><code>in</code></>, <tvar|this><code>this</code></>, or <tvar|word><code>word</code></>, but will then only match <tvar|inthiswordcolon><code>in:this:word</code></>.
<!--T:204-->
Otherwise, remember that for CirrusSearch '''words are letters, numbers, or a combination of the two, and case does not matter'''.
<!--T:205-->
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.
<!--T:206-->
When common words like "of" or "the" are included in a greyspace-phrase, they are ignored, so as to match more aggressively.
<!--T:207-->
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.</translate><ref><translate><!--T:208-->
For example, common terms on this wiki, MediaWiki.org, are, redundantly, (searched):
* udp2log OR udp2log2
* html2wt OR wt2html
* log2ip OR ip2log
There's test2wiki, wiki2xml, wiki2dict, apache2handler, apache2ctl, etc.</translate>
</ref>
<translate>
<!--T:209-->
Now <tvar|camelcase><kbd>camelcase</kbd></> matches <tvar|camelCase><kbd>camelCase</kbd></> because Search is not case sensitive, but <tvar|camelCase2><kbd>camelCase</kbd></> matches <tvar|camelcase2><kbd>camelcase</kbd></> 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.
<!--T:210-->
From the table we can surmise that the basic search <tvar|parser_function><kbd>parser_function -"parser function"</kbd></> is the sum of the basic searches <tvar|parserFunction><code>parserFunction</code></> and <tvar|parser><code>parser&lt;stems> function&lt;stems></code></>.
<!--T:211-->
Making inquiries with numbers, we would find that:
</translate>
<translate>
<!--T:212-->
* <tvar|Plan9><kbd>Plan9</kbd></> or <tvar|Plan_9><kbd>Plan_9</kbd></> matches any of: <tvar|plan9><code>plan9</code></>, <tvar|plans9><code>plans 9</code></>, <tvar|planned9th><code>planned 9th</code></>, <tvar|planned92><code>(planned) 9.2</code></>, <tvar|plans><code>"plans" (9:24)</code></>
* <tvar|plan92><kbd>"plan9"</kbd></> only matches <tvar|plan93><code>plan9</code></> (case insensitive)
* <tvar|planast><kbd>Plan*9</kbd></> matches <tvar|plan94><code>plan9</code></> or <tvar|planet><code>planet4589</code></>.
</translate>
<translate>
<!--T:213-->
The star <tvar|asterisk><kbd>*</kbd></> 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|asterisk1><kbd>*</kbd></> character.
</translate>
<translate>
<!--T:214-->
* 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.
</translate>
<translate>
<!--T:215-->
The <tvar|quest><kbd>\?</kbd></> wildcard represents one letter or number; The <tvar|bsq><kbd>*\?</kbd></> is also accepted, but <tvar|bsqast><kbd>\?*</kbd></> is not recognized.
<!--T:216-->
The wildcards are for basic word, phrase, and insource searches, and may also be an alternative to (some) advanced regex searches (covered later).
<!--T:217-->
Putting a tilde <tvar|tilde><kbd>~</kbd></> character after a word or phrase activates a fuzzy search.
</translate>
<translate>
<!--T:218-->
* 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><kbd>"exact one two phrase"~2</kbd></> matches <tvar|exact><code>exact phrase</code></>.
* 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><kbd>word~0.5</kbd></> (<tvar|wordtilde><kbd>word~.5</kbd></>), 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><kbd>word~2</kbd></> is most fuzzy with an edit distance of 2 (default), and <tvar|wordtilde9><kbd>word~1</kbd></> is least fuzzy, and <tvar|wordtilde12><kbd>word~0</kbd></> is not fuzzy at all.
</translate>
{| style="text-align: center;" class="wikitable"
| ||flowers algernon||Flowers for Algernon||flowers are for Algernon||Flowers a1 2b 3c 4f 5j 6l 7j 8p q9 z10 for Algernon
|-
|"flowers algernon"||{{Tick}}||{{Cross}}||{{Cross}}||{{Cross}}
|-
|"flowers algernon"~0||{{Tick}}||{{Cross}}||{{Cross}}||{{Cross}}
|-
|"flowers algernon"~1||{{Tick}}||{{Tick}}||{{Cross}}||{{Cross}}
|-
|"flowers algernon"~2||{{Tick}}||{{Tick}}||{{Tick}}||{{Cross}}
|-
|"flowers algernon"~11||{{Tick}}||{{Tick}}||{{Tick}}||{{Tick}}
|-
|"algernon flowers"~1||{{Cross}}||{{Cross}}||{{Cross}}||{{Cross}}
|-
|"algernon flowers"~2||{{Tick}}||{{Cross}}||{{Cross}}||{{Cross}}
|-
|"algernon flowers"~3||{{Tick}}||{{Tick}}||{{Cross}}||{{Cross}}
|-
| "algernon flowers"~4||{{Tick}}||{{Tick}}||{{Tick}}||{{Cross}}
|-
|"algernon flowers"~13||{{Tick}}||{{Tick}}||{{Tick}}||{{Tick}}
|}
<translate>
<!--T:219-->
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 <tvar|and><kbd>AND</kbd></> is required between two phrases because otherwise the two "inner" "quotation marks" are confused.
</translate>
<translate>
<!--T:37-->
Quotes turn off stemming, <tvar|appendtilde><kbd>"but appending"~</kbd></> the tilde reactivates the stemming.
</translate>
{| style="text-align: center;" class="wikitable"
| ||flowers||flower||Flowers for Algernon||flower for Algernon
|
|-
|flowers ||{{Tick}}||{{Tick}}||{{Tick}}||{{Tick}}
|<translate><!--T:220--> Stemming is in effect.</translate>
|-
|"flowers"||{{Tick}}||{{Cross}}||{{Tick}}||{{Cross}}
|<translate><!--T:221--> Proximity search turns off stemming. </translate>
|-
|"flowers"~||{{Tick}}||{{Tick}}||{{Tick}}||{{Tick}}
|<translate><!--T:222--> Proximity plus stemming by suffixing a tilde. </translate>
|-
|"flowers for algernon"||{{Cross}}||{{Cross}}||{{Tick}}||{{Cross}}
|<translate><!--T:223--> Proximity search turns off stemming. </translate>
|-
|style=white-space:nowrap|"flowers for algernon"~||{{Cross}}||{{Cross}}||{{Tick}}||{{Tick}}
|<translate><!--T:224--> Proximity plus stemming by suffixing a tilde. </translate>
|-
|"flowers algernon"~1||{{Cross}}||{{Cross}}||{{Tick}}||{{Cross}}
|<translate><!--T:225--> Proximity search turns off stemming. </translate>
|-
|style=white-space:nowrap|"flowers algernon"~1~||{{Cross}}||{{Cross}}||{{Tick}}||{{Tick}}
|<translate><!--T:226--> Proximity plus stemming by suffixing a tilde. </translate>
|}
{{anchor|Insource}}
<translate>
==== Insource ==== <!--T:227-->
</translate>
{{MW version|version=1.24|compact=y|comment=and after|gerrit change=137733}}
<translate>
<!--T:228-->
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, on any page except redirects. This phrase completely ignores greyspace: <tvar|issa><kbd>insource: "state state autocollapse"</kbd></> matches <tvar|state><code>|state=<nowiki>{{{state|autocollapse}}}</nowiki></code></>.
</translate>
{| class="wikitable" style="background-color:white"
|<kbd>insource:&nbsp;word</kbd><br /><kbd>insource:&nbsp;"''word1''&nbsp;''word2''"</kbd>
|
<translate><!--T:229--> Greyspace characters are ignored, just as they are with word searches and exact-phrase searches.</translate>
|-
|<kbd>insource:/''regexp''/</kbd><br /><kbd>insource:/''regexp''/i</kbd>
|
<translate><!--T:230--> These are [[<tvar|regex>w:regular expression</>|regular expressions]]. They aren't efficient, so we can only allow a few at a time on the search cluster, but they are very powerful. The version with the extra <tvar|i><code>i</code></> runs the expression case-insensitive, and is even less efficient.</translate>
|}
<translate>
<!--T:231-->
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.</translate><ref><translate><!--T:432--> CirrusSearch regex do not address the newline character directly, but a dot <tvar|dot><kbd>.</kbd></> will match a newline.</translate></ref> <translate><!--T:433--> 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.</translate><ref><translate><!--T:434--> A wallowing regex search cannot disable Search, but can disable another's regex search.</translate></ref>. <translate><!--T:435-->
Insource can play both roles, and the best candidate for <tvar|insourcearg><kbd>insource:/''arg''/</kbd></> is often <tvar|insourcearg2><kbd>insource: ''arg''</kbd></>, where ''arg'' is the same.
<!--T:232-->
The syntax for the regexp is <tvar|insource><kbd>insource:</kbd></> no space, and then <tvar|regexp><kbd>/''regexp''/</kbd></>.  (No other parameter disallows a space. All the parameters except <tvar|regex><kbd>insource:/''regexp''/</kbd></> generously accept space after their colon.)
<!--T:233-->
Insource indexed-search and regexp-search roles are similar in many respects:
</translate>
<translate>
<!--T:234-->
* Both search wikitext only.
* Neither finds things "sourced" by a [[<tvar|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.
</translate>
<translate>
<!--T:235-->
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 and all'' characters, for example a sequence of two spaces. Regex are an entirely different class of search tool that make matching a literal string easy (basic, beginner use), and make matching by metacharacter expressions possible (advanced use) on the wiki.  See [[<tvar|regexanchor>#Regular expression searches</>]] below.
</translate>
{{Note|1=<translate><!--T:236--> The ''insource'' parameter treats words with embedded colons as one word. This affects search queries for templates, parser functions, URLs, wikilinks, HTML tags, and comments.</translate>}}
{{tip|1=<translate><!--T:237--> When possible, please avoid running a bare regexp search. See how this is always possible at [[<tvar|regexanchor>#Regular expression searches</>]], below.</translate>}}
{{tip|1=<translate><!--T:449--> To search for words that begin with <tvar|dash><kbd>-</kbd></> or <tvar|exclaim><kbd>!</kbd></>, such as <tvar|inlaw><kbd>-in-law</kbd></> or <tvar|kung><kbd>!Kung</kbd></>, use a case-insensitive <tvar|insource><kbd>insource</kbd></> query together with a simple search on the "plain" version of the term (to avoid a bare regexp search). For example, <tvar|isinlaw><code>"in-law" insource:/-in-law/i</code></> or <tvar|iskung><code>"kung" insource:/!kung/i</code></>.</translate>}}
{{anchor|Prefix and namespace}}
<translate>
=== Prefix and namespace === <!--T:238-->
<!--T:372-->
For Search, a namespace term functions to specify the initial search domain. Instead of searching the entire wiki, the default is the main namespace (mainspace).
<!--T:373-->
Only one namespace name can be set from the search box query.  It is either the first term or in the last term, in a  ''prefix'' parameter.
<!--T:374-->
Two or more namespaces may be searched from the ''Advanced'' pane of the '''search bar''' found on the top of every search results page, [[Special:Search]].  Your search domain, as a profile of namespaces, can be set here (without going to the user preferences page). The namespaces list will then present itself on the first page of future search results to indicate the search domain of the search results. To unset this, select the default namespace (shown in parentheses), select "Remember", and press Search.
<!--T:375-->
The '''search bar''' graphically sets and indicates a search domain. "Content pages" (mainspace), "Multimedia" (File), "Everything" (''all'' plus File), "Translations", etc., are hyperlinks that can activate the query in that domain, and then indicate this by going inactive (dark).  But the query will override the search bar.  When a namespace or prefix is used in the query the search bar activations and indications may be misleading, so the search bar and the search box are mutually exclusive (not complementary) ways to set the search domain.
<!--T:376-->
A namespace term overrides the search bar, and a ''prefix'' term overrides a namespace.
<!--T:158-->
Enter a namespace name, or enter <tvar|all><code>all:</code></>, or enter a  '''<tvar|colon><big><code>:</code></big></>''' colon for mainspace.</translate>
<translate>
<!--T:377-->
''All'' does not include the File namespace. File includes media content held at Commons such as PDF, which are all indexed and searchable.
</translate>
<translate>
<!--T:240-->
When File is involved, a namespace modifier <tvar|local><code>local:</code></> has an effect, otherwise it is ignored.
</translate>
<translate>
<!--T:159-->
Namespace aliases are accepted.</translate>
{|class=wikitable style=background-color:white
| <kbd>talk: "Wind clock"</kbd>
| <translate><!--T:242--> Find pages in the '''Talk''' namespace whose title or text contains the phrase "wind clock".</translate>
|-
| <kbd>file: "Wind clock"</kbd>
| <translate><!--T:244--> Find pages in '''File''' namespace, whose title, text, or media content contains the phrase "wind clock".</translate>
|-
| style="white-space:nowrap"| <kbd>file: local: "Wind clock"</kbd>
| <translate><!--T:246--> Filter out results from Commons wiki.</translate>
|-
| <kbd>local: "Wind clock"</kbd>
| <translate><!--T:248--> Ignored.</translate> <translate><!--T:378--> Searches mainspace. Local is ignored unless File is involved.</translate>
|}
<translate>
<!--T:379-->
As with search parameters, ''local'' and ''all'' must be lowercase. Namespaces names are case insensitive.
<!--T:380-->
The <tvar|prefixcolon><kbd>prefix:</kbd></> parameter matches any number of first-characters of all pagenames in one namespace.</translate><ref> <translate><!--T:436--> Prefix does not match on first-characters of fullpagenames, so you cannot search two namespaces at once just because they start with the same letters, such as both ''namespace'' and ''namespace talk'' in one query.</translate></ref> <translate><!--T:437-->
When the first letters match a namespace name and colon, the search domain changes.
</translate>
<translate>
<!--T:381-->
Given a namespace only, ''prefix'' will match all its pagenames.  Given one character only, it cannot be - dash or ' quote or " double quote.  The last character cannot be a colon.
</translate>
<translate>
<!--T:382-->
For pagenames that match, their subpage titles match by definition.
</translate>
<translate>
<!--T:383-->
The ''prefix'' parameter does not allow a space before a namespace, but allows whitespace before a pagename.
</translate>
{| class="wikitable" style=background-color:white
|-
| <kbd>prefix:</kbd><kbd>cow</kbd>
| <translate><!--T:91--> Find pages in mainspace whose title starts with the three letters <tvar|c_o_w><kbd>c o w</kbd></>.</translate>
|-
| <kbd>domestic</kbd>&nbsp;&nbsp;&nbsp;<kbd>prefix:</kbd><kbd>cow</kbd>
| <translate><!--T:92--> Find pages in mainspace whose title starts with the three letters <tvar|c_o_w2><kbd>c o w</kbd></>, and that contain the word "<tvar|domestic2><kbd>domestic</kbd></>".</translate>
|-
| <kbd>domestic</kbd>&nbsp;&nbsp;&nbsp;<kbd>prefix:</kbd><kbd>cow/</kbd>
| <translate><!--T:93--> List any existing subpages of ''<tvar|Cow>Cow</>'' but only if they contain the word "<tvar|domestic5>domestic</>".</translate> <translate><!--T:94--> This is a very common search and is frequently built using a special URL parameter called <tvar|prefixequal><kbd>prefix=</kbd></>.</translate>
|-
| style=" white-space:nowrap;"|<kbd>domestic</kbd>&nbsp;&nbsp;&nbsp;<kbd>prefix:</kbd><kbd>Talk:cow</kbd>/
| <translate><!--T:384--> List any subpages of ''<tvar|talkcow2>Talk:cow</>'', but only if they contain the word "<tvar|domestic6>domestic</>".</translate>
|-
| style=white-space:nowrap | <kbd>1967</kbd>&nbsp;&nbsp;&nbsp;<kbd>prefix:</kbd><kbd>Pink Floyd</kbd>/
| <translate><!--T:385--> List any subpages of ''Pink Floyd'', but only if it also contains the word "1967".</translate>
|}
<translate>
<!--T:386-->
The ''prefix'' parameter goes at the end so that pagename characters may contain " quotation marks. 
<!--T:255-->
The [[<tvar|extrans>Extension:Translate</>|Translate extension]] creates a sort of "language namespace", of translated versions of a page.  But unlike namespace or prefix, which create the initial search domain, the <tvar|inlang><kbd>inlanguage</kbd></> parameter is a ''filter'' of it.  (See the next section.)
=== Exclude content from the search index === <!--T:439-->
<!--T:440-->
Content can be excluded from the search index by adding <tvar|css-class><code>class="navigation-not-searchable"</code></>. This will instruct CirrusSearch to ignore this content from the search index (see <tvar|phab>{{phab|T162905}}</> for more context).
<!--T:441-->
Additionally content can be marked as auxiliary information by adding <tvar|css-class><code>class="searchaux"</code></>. This will instruct CirrusSearch to move the content from the main text to an auxiliary field which has lower importance for search and snippet highlighting. This distinction is used for items such as image thumbnail descriptions, 'see also' sections, etc.
== Filters == <!--T:256-->
<!--T:387-->
A filter can have multiple instances, and negated instances, and it can run as a standalone filtering a search domain.  A query is formed as terms that filter a search domain.  A namespace or a ''prefix'' term is not a filter because a namespace will not run standalone, and a ''prefix'' will not negate.
<!--T:388-->
Adding another word, phrase, or parameter filters more. A highly refined search result may have very many Y/N filters when every page in the results will be addressed. (In this case ranking is largely irrelevant.) Filtering applies critically to adding a regex term; you want as few pages as possible before adding a regex (because it can never have a prepared index for its search).
<!--T:370-->
The search parameters below are filters.
<!--T:389-->
''Insource'' (covered above) is also a filter, but <tvar|regexp><kbd>insource:/''regexp''/</kbd></> is not a filter. Filters and all other search parameters are lowercase. (Namespaces are an exception, being case insensitive.)
=== Intitle and incategory === <!--T:258-->
<!--T:259-->
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''.
<!--T:260-->
* <tvar|cowast><kbd>cow*</kbd></>
** Find articles whose title or text contains words that start with cow
</translate>
<translate>
<!--T:51-->
* <tvar|itfoo><kbd>intitle:foo</kbd></>
** Find articles whose title contains foo. Stemming is enabled for foo.
* <tvar|itfineline><kbd>intitle:"fine line"</kbd></>
** Find articles whose title contains ''fine line''. Stemming is disabled.
* <tvar|itfoobar><kbd>intitle:foo bar</kbd></>
** Find articles whose title contains foo and whose title or text contains bar.
* <tvar|itfoo_bar><kbd>-intitle:foo bar</kbd></></translate>
<translate>
<!--T:52-->
** Find articles whose title does not contain foo and whose title or text contains bar.
* <tvar|icmusic><kbd>incategory:Music</kbd></>
** Find articles that are in Category:Music
* <tvar|icmusichistory><kbd>incategory:"music history"</kbd></>
** Find articles that are in Category:Music_history</translate>
<translate>
<!--T:53-->
* <tvar|icmusicals><kbd>incategory:"musicals" incategory:"1920"</kbd></>
** Find articles that are in both Category:Musicals and Category:1920
* <tvar|icmusicalsnot><kbd>-incategory:"musicals" incategory:"1920"</kbd></>
** Find articles that are not in Category:Musicals but are in Category:1920
</translate>
<translate>
<!--T:261-->
Intitle and ''incategory'' are old search parameters. Incategory no longer searches any subcategory automatically, but you can now add multiple category pagenames manually. </translate>
=== Deepcategory ===
<translate>
<!--T:460-->
Deep category search allows to search in category and all subcategories. The depth of the tree is limited by 5 levels currently (configurable) and the number of categories is limited by 256 (configurable). The deep search uses [[<tvar|1>Special:MyLanguage/Wikidata Query Service/Categories</>|SPARQL Category service from WDQS]]. Keywords are ''deepcategory'' or ''deepcat''. Example:
* <tvar|dcmusicals><kbd>deepcat:"musicals"</kbd></>
** Find articles that are in Category:Musicals or any of the subcategories.
<!--T:461-->
Previously this parameter was implemented by a gadget: to get the search parameter ''deepcat'', to automatically add up to 70 subcategories onto an ''incategory'' parameter, <tvar|incategory><kbd>incategory:''category1''|''category2''|...|''category70''</kbd></>,&nbsp;
you can add a line to your Custom JavaScript.</translate><ref><translate><!--T:438-->
Edit [[Special:Preferences#mw-prefsection-rendering|your Custom JavaScript]], and add
:<tvar|gadgt><small><kbd>mw.loader.load( "//de.wikipedia.org/wiki/MediaWiki:Gadget-DeepCat.js&action=raw&ctype=text/javascript" );</kbd></small></><br />
See {{phab|T37402}}.</translate></ref>
<translate>
=== Linksto === <!--T:262-->
<!--T:263-->
''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 {<nowiki/>{FULLPAGENAME}}, e.g. {{FULLPAGENAME}}.)
<!--T:264-->
''Linksto'' does not find redirects. It only finds [<nowiki />[wikilinks]], even when they are made by a template.</translate>
<translate>
<!--T:390-->
It does not find a link made by a URL, even if that URL is an internal wiki link.
<!--T:265-->
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:
</translate>
# linksto: "Help:Cirrus Search"
# linksto: Help:Searching
# linksto: H:S
<translate>
<!--T:267-->
<tvar|linksto><code>CirrusSearch -linksto: Help:CirrusSearch</code></> finds articles that mention "<tvar|CirrusSearch>CirrusSearch</>" but not in a wikilink.
</translate>
<translate>
=== Hastemplate === <!--T:268-->
<!--T:269-->
You can specify template usage with <tvar|hastemplate><code>hastemplate: ''template''</code></>. 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. (Compare ''boost-template'' no default namespace; ''linksto'' no namespace aliases, case-sensitive, no redirects; ''intitle'' no redirects.)
<!--T:270-->
''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.
<!--T:271-->
* <tvar|hastempquality><kbd>hastemplate: "quality image"</kbd></>, finds "<tvar|tempquality>Template:Quality image</>" usage in your default search domain (namespaces).
* <tvar|hastportal><kbd>: hastemplate: portal:contents/tocnavbar</kbd></>, finds mainspace usage of a "<tvar|tocnavbar>Contents/TOCnavbar</>" template in the Portal namespace.
<!--T:391-->
For installations with the Translate extension, ''hastemplate'' searches get interference wherever [[Template:Translatable template name]] wraps the template name of a translatable template.  Use ''insource'' instead.
</translate>
<translate>
=== Inlanguage === <!--T:392-->
<!--T:393-->
For installations with the Translate extension, <tvar|inlang><kbd>inlanguage</kbd></> is important for highly refined searches and page counts.
</translate>
:<kbd>inlanguage: ''<translate><!--T:394--> [[w:List of ISO 639-2 codes|language code]]</translate>''</kbd>
<translate>
<!--T:395-->
will produce search results in that language only.
<!--T:368-->
For example
<!--T:396-->
* to count all Japanese pages on the wiki
</translate>
: <kbd>all: inlanguage: ja</kbd>
<translate>
<!--T:397-->
* to filter out German and Spanish pages in the Help namespace
</translate>
: <kbd>help: -inlanguage: de -inlanguage: es</kbd>
<translate>
<!--T:398-->
* to ignore Translate, and where English is the base language, add
</translate>
: <kbd>inlanguage:en</kbd>
=== Contentmodel ===
<translate>
<!--T:425-->
The <tvar|contentmodel><kbd>contentmodel:</kbd></> keyword allows to limit the search to pages of a specific content model. For possible models cf. [[<tvar|cthandle>Special:MyLanguage/Content handlers</>|Content handlers]]. E.g.:
<!--T:426-->
* To see only JSON pages:
</translate>
: <kbd>contentmodel:json</kbd>
<translate>
=== subpageof === <!--T:450-->
<!--T:451-->
To find sub-pages.
</translate>
:<kbd>subpageof: ''<translate><!--T:452--> ParentPage</translate>''</kbd>
<translate><!--T:453-->
For example
<!--T:454-->
* To find all subpages of CirrusSearch.
</translate>
: <kbd>subpageof:CirrusSearch</kbd>
<translate>
<!--T:455-->
* Use double quotes if the parent page contains spaces.
</translate>
: <kbd>subpageof:"Requests for comment"</kbd>
<translate>
<!--T:456-->
NOTE: unlike ''prefix:'', do not include the page namespace in the keyword value. If you want to limit to sub-pages of a particular namespace use the namespace filter.
== Page weighting == <!--T:272-->
<!--T:273-->
Weighting determines snippet, suggestions, and page relevance. The normal weight is one.  Additional weighting is given through multipliers.
<!--T:274-->
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.
</translate>
<translate>
=== Morelike === <!--T:275-->
</translate>
* <kbd>morelike:''page name 1''|''page name 2''|...|''page name n''</kbd>
<translate>
<!--T:27-->
** Find articles whose text is most similar to the text of the given articles.
</translate>
* <kbd>morelike:wasp|bee|ant</kbd>
** <translate><!--T:152--> Find articles about stinging insects.</translate>
* <kbd>morelike:template:search|template:regex|template:usage</kbd>
** <translate><!--T:153--> Find templates about regex searching for template usage on the wiki.</translate>
<translate>
<!--T:90-->
The <tvar|morelike><kbd>morelike:</kbd></> 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:
* <tvar|cmmindf><kbd>cirrusMltMinDocFreq</kbd></>: Minimum number of documents (per shard) that need a term for it to be considered.
* <tvar|cmmaxdf><kbd>cirrusMltMaxDocFreq</kbd></>: Maximum number of documents (per shard) that have a term for it to be considered.
* <tvar|cmmaxqt><kbd>cirrusMltMaxQueryTerms</kbd></>: Maximum number of terms to be considered.
* <tvar|cmmintf><kbd>cirrusMltMinTermFreq</kbd></>: Minimum number of times the term appears in the input to doc to be considered. For small fields (<tvar|title><kbd>title</kbd></>) this value should be 1.
* <tvar|cmminwl><kbd>cirrusMltMinWordLength</kbd></>: Minimal length of a term to be considered. Defaults to 0.
* <tvar|cmmaxwl><kbd>cirrusMltMaxWordLength</kbd></>: The maximum word length above which words will be ignored. Defaults to unbounded (0).
* <tvar|cmf><kbd>cirrusMltFields</kbd></> (comma separated list of values): These are the fields to use. Allowed fields are <tvar|title><kbd>title</kbd></>, <tvar|text><kbd>text</kbd></>, <tvar|auxtext><kbd>auxiliary_text</kbd></>, <tvar|opening><kbd>opening_text</kbd></>, <tvar|headings><kbd>headings</kbd></> and <tvar|all><kbd>all</kbd></>.
* <tvar|cmuf><kbd>cirrusMltUseFields</kbd></> (<tvar|true><code>true</code></>|<tvar|false><code>false</code></>): use only the field data. Defaults to <tvar|false2><code>false</code></>: the system will extract the content of the <tvar|text2><code>text</code></> field to build the query.
* <tvar|cmpttm><kbd>cirrusMltPercentTermsToMatch</kbd></>: The percentage of terms to match on. Defaults to 0.3 (30 percent).
* Example: <tvar|cmufcode><code>&cirrusMtlUseFields=yes&cirrusMltFields=title&cirrusMltMinTermFreq=1&cirrusMltMinDocFreq=1&cirrusMltMinWordLength=2</code></>
These settings can be made persistent by overriding <tvar|cirrusmlt><code>cirrussearch-morelikethis-settings</code></> in [[<tvar|hlpsysmsg>Special:MyLanguage/Help:System message</>]].
</translate>
=== Prefer-recent ===
<translate>
<!--T:399-->
Adding <tvar|pr><kbd>prefer-recent:</kbd></> anywhere in the query gives recently edited articles a slightly larger than normal boost in the page-ranking rules.</translate>
<translate>
<!--T:471-->
Prefer-recent is only applied when using the default <tvar|1><code>relevance</code></> [[<tvar|2>#Explicit sort orders</>|sort order]].
<!--T:400-->
It defaults to boost only 60% of the score, in a large, 160 day window of time, which can be entered in the query as <tvar|pr2><kbd>prefer-recent:0.6,160</kbd>.</> This plays well with other page ranking rules, and is intended for most searches.
<!--T:401-->
You can manipulate the rules: <tvar|pr-boost><kbd>prefer-recent:''boost'',''recent''</kbd></></translate>
<translate>
<!--T:402-->
Technically "boost" is the proportion of score to scale, and "recent" is the half life in days.</translate>
<translate>
<!--T:403-->
The boost is more than the usual ''multiplier'', it is an ''[[<tvar|exd>w:Exponential_decay</>|exponential]]'' boost.</translate>
<translate>
<!--T:404-->
The factor used in the exponent is the time since the last edit.
<!--T:405-->
For example
</translate>
:<kbd>prefer-recent:,7</kbd>
<translate>
<!--T:406-->
Pages older than 7 days are boosted half as much, and pages older than 14 days are boosted half as much again, and so on.
</translate>
<translate>
<!--T:407-->
For a simple "sort by date" in highly refined search results, where page ranking and boosting are largely meaningless, just boost the entire score.
</translate>
* <kbd>prefer-recent:1,7</kbd> (weeks)
* <kbd>prefer-recent:1,1</kbd> (days)
* <kbd>prefer-recent:1,0.0007</kbd> (minutes)
* <kbd>prefer-recent:1,0.0001</kbd> (8.64 seconds)
* <kbd>prefer-recent:1,0.00001</kbd> (seconds)
<translate>
=== Boost-templates === <!--T:408-->
<!--T:45-->
You can boost pages' scores based on what templates they contain. This can be done directly in the search via <tvar|bt><code>boost-templates:""</code></> or you can set the default for all searches via the new <tvar|cbt><code>MediaWiki:cirrussearch-boost-templates</code></> message. <tvar|btempty><code>boost-templates:""</code></> replaces the contents of <tvar|cbtempty><code>cirrussearch-boost-templates</code></> if the former is specified. The syntax is a bit funky but was chosen for simplicity.</translate>
<translate>
<!--T:472-->
Like prefer-recent, boost-templates is only applied when using the default <tvar|1><code>relevance</code></> [[<tvar|2>#Explicit sort orders</>|sort order]].</translate>
<translate>
<!--T:473-->
Some examples:
</translate>
;<kbd>File:boost-templates:"Template:Quality Image|200%" incategory:china</kbd>
<translate>
<!--T:55-->
:Find files in the China category sorting quality images first.
</translate>
;<kbd>File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" incategory:china</kbd>
<translate>
<!--T:56-->
:Find files in the China category sorting quality images first and low quality images last.</translate>
<translate>
<!--T:283-->
;<tvar|tqpop><kbd>File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" popcorn</kbd></>
:Find files about popcorn sorting quality images first and low quality images last. Remember that through the use of the <tvar|sbt1><code>cirrussearch-boost-templates</code></> message this can be reduced to just <tvar|popcorn><code>popcorn</code></>.
<!--T:46-->
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.
<!--T:47-->
A word of warning about <tvar|csbt><code>cirrussearch-boost-templates</code></>: 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|bnws><code>brave new world</code></> would find a featured article with those words scattered throughout it instead of the article for [[<tvar|bnw>w:Brave New World</>|Brave New World]].</translate>
{{anchor|Regular expression searches}}
<translate>
== Regular expression searches == <!--T:284-->
<!--T:285-->
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.
<!--T:286-->
These return ''much much'' faster when you limit the regexp search-domain to the results of one or more index-based searches.
<!--T:287-->
'''Warning:''' Do not run a bare <tvar|insreg><kbd>insource:/''regexp''/</kbd></> search.  It will probably timeout after 20 seconds anyway, while blocking responsible users.
<!--T:288-->
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:
</translate>
* <kbd>insource:"debian.reproducible.net" insource:'''<big>/</big>'''debian\.reproducible\.net'''<big>/</big>'''</kbd>
* <kbd>insource:"c:\program files (x86)" insource:'''<big>/</big>'''C\:\\Program Files \(x86\)'''<big>/i</big>'''</kbd>
* <kbd>insource:"<''tag''>{<nowiki/>{''template''}}</''tag''>" insource:<big>'''/'''</big>"<''tag''>{<nowiki/>{''template''}}<\/''tag''>"<big>'''/'''</big></kbd>
* <kbd>insource:"[<nowiki/>[''title''|''link label'']]'s" insource:<big>'''/'''</big>"[<nowiki/>[''title''|''link label'']]'s"<big>'''/'''</big></kbd>
* <kbd>insource:<big>'''/'''</big>''regexp''<big>'''/'''</big> '''prefix:{<nowiki/>{FULLPAGENAME}}'''</kbd>
<translate>
<!--T:290-->
The last example works from a link on a page, but <tvar|fullpagename>{<nowiki/>{[[FULLPAGENAME]]}}</> doesn't function in the search box.
<!--T:291-->
For example: <tvar|exampleofsearch><kbd><nowiki>[[Special:Search/insource:/regex/&nbsp;prefix:{{FULLPAGENAME}}]]</nowiki></kbd></> [[<tvar|exampleofsearch2>Special:Search/insource:/regex/ prefix:{{FULLPAGENAME}}</>| finds the term ''regex'' on this page]].
<!--T:292-->
A query with no namespace specified and no prefix specified searches your default search domain, (settable on any search-results page, i.e. at ''[[<tvar|ss>Special:Search</>]]''). Some users keep their default search domain at "all namespaces", i.e. the entire wiki. On a large wiki if this user does a bare regexp search it will probably fail, incurring an HTML timeout, before completing the search.
<!--T:293-->
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 an <tvar|insource>''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:
</translate>
<translate>
<!--T:294-->
* ''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.
</translate>
<translate>
<!--T:409-->
To test a bare regexp query you can create a page with test patterns, and then use the ''prefix'' parameter with that fullpagename.</translate>
<translate>
<!--T:410-->
The match will be highlighted.</translate>
<translate>
<!--T:411-->
It searches that page (in the database) and its subpages.
<!--T:296-->
Search terms that do not increase the efficiency of a regexp search are the page-scoring operators: ''morelike'', ''boost-template'', and ''prefer-recent''.
</translate>
{{anchor|Metacharacters}}
<translate>
==== Metacharacters ==== <!--T:139-->
<!--T:140-->
This section covers how to escape metacharacters used in rexexp searches</translate>
<translate>
<!--T:168-->
For the actual meaning of the metacharacters see the [<tvar|link1>https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax</> explanation of the syntax].</translate>
<ref><translate>
<!--T:130-->
For the formal definition see the [<tvar|link2>http://lucene.apache.org/core/4_8_1/core/org/apache/lucene/util/automaton/RegExp.html</> Lucene grammar for regular expressions].
</translate></ref>
{{tip|1=<translate><!--T:297--> The use of an exact string requires a regexp, but the regexp term obligates the search to limit itself. ''Add'' a regexp term, never search a bare regexp. ''Start'' by noting the number of pages in a previous search before committing an exact string search. Querying with an exact string requires a filtered search domain.</translate>}}
<translate>
<!--T:298-->
For example:
<!--T:299-->
* 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.
==== Refining with an exact string ==== <!--T:300-->
<!--T:443-->
* 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.
<!--T:301-->
You can start out intending an exact string search, but keep in mind:
<!--T:302-->
* 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.
<!--T:303-->
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.
<!--T:304-->
* 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. 
<!--T:305-->
'''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.
<!--T:306-->
* <tvar|pntemp><code>/"[<nowiki/>[page/name|{<nowiki/>{temp-late"/</code></> instead of <tvar|pntemp-late><code>/\[\[page\/name\|\{\{temp\-late/</code></>
* <tvar|literal><code>/"literal back\slash"/</code></> is as good as <tvar|literal2><code>/literal back\/slash/</code></>
* But <tvar|thisfails><code>/"This \" fails"/</code></> always. 
* And <tvar|thisdepends><code>/"This \/ depends"/</code></>.  It finds the <tvar|vvv><code>\/</code></> literally, which is not the <tvar|slash><code>/</code></> you probably wanted.
<!--T:307-->
'''Backslash-escape''' using insource:/''regexp''/ allows escaping the " and / delimiters,  but requires taking into account metacharacters, and escaping any:
<!--T:308-->
* To match a <tvar|slash2><code>/</code></> delimiter character use <tvar|vvv2><code>\/</code></>.
* To match a <tvar|quote><code>"</code></> delimiter character use <tvar|slashquote><code>\"</code></>.
* The escaped metacharacters would be <tvar|grawlix2><code>\~\@\#\&\*\(\)\-\+\{\}\[\]\|\<\>\?\.\\</code></>.
* The equivalent expression escaped with double-quotes is <tvar|grawlix3><code>"~@#&*()-+{}[]|\<>?.\"</code></>.
<!--T:309-->
The simplest algorithm to create the basic string-finding expression using insource:/"''regexp''"/, need not take metacharacters into account except for the " and / characters:
<!--T:310-->
# Write <tvar|str_ing><code>the/str"ing</code></> out. (The /" delimiters "/ are not shown.)
# Replace <tvar|doublequote><code>"</code></> with <tvar|slashdoublequote><code>"\""</code></> (previous double-quote: stop, concatenate, quote restart).
# Replace <tvar|slash4><code>/</code></> with <tvar|vvv3><code>"\/"</code></> (stop, concatenate, start).
# You get <tvar|insource><code>insource:/"the"\/"str"\""ing"/</code></>, showing concatenation of the two methods.
</translate>
{{tip|1=<translate><!--T:311--> While refining a regexp on a search results page, keep in mind that the snippet "wikitext" has modified spacing.  Regex are sensitive to space characters, so copying from snippets is dangerous.</translate>}}
<translate>
<!--T:312-->
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><code>[-.\]]</code></> or <tvar|code2><code>[].\-]</code></>.
<!--T:313-->
For general examples using metacharacters:
</translate>
<translate>
<!--T:314-->
*<tvar|insource0><kbd>insource:"2+2=4" insource:/"2+2=4"/</kbd></> matches "2 + 2 = 4", with zero spaces between the characters.
*<tvar|insource01><kbd>insource:"2 + 2 = 4" insource:/2 ?\+ ?2 ?= ?4\./</kbd></>  match with zero or one space in between. The equals = sign is not a metacharacter, but the plus + sign is.
*<tvar|insourcetag><kbd>insource:"<''tag''>[<nowiki/>[link|2\3?]]\</''tag''>" insource:/"<''tag''>[<nowiki/>[link|2\3?]]<'''<big>"\/"</big>'''''tag''>"/</kbd></>.
</translate>
<translate>
<!--T:315-->
There are some notable differences from standard regex metacharacters:
<!--T:442-->
* The <tvar|code1><code>\n</code></> or <tvar|code2><code>\r\n</code></> are not reserved for matching a newline.</translate> <translate><!--T:481--> To search for a string that contains a newline, you can do a search like <tvar|1><code><nowiki>insource:/[^\}]\}\}[^\} \|][^\} \|]\<noinclude/i</nowiki></code></> which means not a curly brace, then two curly braces, then any two characters except a curly brace, space, or pipe, then a <tvar|2>{{tag|noinclude|open}}</> tag.</translate> <translate><!--T:482--> The "any character except" will include a newline in the search.</translate> <translate><!--T:483--> Note thas this search was designed only to match to the following string:</translate>
:<source>
}}
<noinclude>
</source><!-- "source" instead of "pre" to preserve indentation -->
<translate>
<!--T:316-->
* 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.
* < and > 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.
====Regex on titles==== <!--T:468-->
<!--T:469-->
The <tvar|1><kbd>insource</kbd></> keyword does only search the page source content.</translate>
<translate>
<!--T:470-->
To run regex searches on the title strings <tvar|1><kbd>intitle://</kbd></> can be used.
====Advanced example==== <!--T:147-->
<!--T:131-->
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><code>fmt=commas</code></> having any allowable spaces around it, (it could be the same template call, or a separate one):
</translate>
:<small><code>hastemplate:val insource:"fmt commas" insource:<big>'''/'''</big>\{\{val\|[^}]*fmt *= *commas/ insource:/\{val\| *[-+]?[0-9]{3,4} *[|}]<big>'''/'''</big></code></small>
<translate>
<!--T:412-->
Note that the = sign in "fmt commas" is not needed but that adding it would not change the search results.</translate>
<translate>
<!--T:132-->
It is fast because it uses two filters so that every page the regexp crawls has the highest possible potential.
== Geo Search == <!--T:169-->
=== bounded === <!--T:170-->
<!--T:360-->
You can limit search to pages identified as being near some specified geographic coordinates.</translate>
<translate>
<!--T:361-->
The coordinates can either be specified as a <lat>,<lon> pair, or by providing a page title from which to source the coordinates.</translate>
<translate>
<!--T:362-->
A distance to limit the search to can be prepended if desired.</translate>
<translate>
<!--T:363-->
Examples:
</translate>
* <kbd>neartitle:"San Francisco"</kbd>
* <kbd>neartitle:"100km,San Francisco"</kbd>
* <kbd>nearcoord:37.77666667,-122.39</kbd>
* <kbd>nearcoord:42km,37.77666667,-122.39</kbd>
<translate>
=== boosted === <!--T:172-->
<!--T:364-->
You can alternatively increase the score of pages within a specified geographic area.</translate>
<translate>
<!--T:365-->
The syntax is the same as bounded search, but with boost- prepended to the keyword.</translate>
<translate>
<!--T:366-->
This effectively doubles the score for pages within the search range, giving a better chance for nearby search results to be near the top.
</translate>
* <kbd>boost-neartitle:"San Francisco"</kbd>
* <kbd>boost-neartitle:"100km,San Francisco"</kbd>
* <kbd>boost-nearcoord:37.77666667,-122.39</kbd>
* <kbd>boost-nearcoord:42km,37.77666667,-122.39</kbd>
<translate>
== File properties search == <!--T:318-->
</translate>
{{MW version|version=1.28|compact=y|comment=and after|gerrit change=311061}}
<translate>
<!--T:319-->
Since MediaWiki 1.28, CirrusSearch supports indexing and searching of properties of files in the <tvar|file><code>File:</code></> namespace. This includes:
* file media type
* MIME type
* size
* width & height
* resolution
* bit depth for files that support these
</translate>
{{tip|1=<translate><!--T:320--> While these predicates are useful only for files, they by themselves do not limit search to <code>File:</code> namespace. It is recommended to include this namespace in a search or restrict the search to only this namespace when using these conditionals.</translate>}}
<translate>
=== filetype === <!--T:321-->
<!--T:367-->
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:
</translate>
* <code>UNKNOWN</code>
* <code>BITMAP</code>
* <code>DRAWING</code>
* <code>AUDIO</code>
* <code>VIDEO</code>
* <code>MULTIMEDIA</code>
* <code>OFFICE</code>
* <code>TEXT</code>
* <code>EXECUTABLE</code>
* <code>ARCHIVE</code>
<translate>
<!--T:323-->
This list may be extended in the future. See also <tvar|mediatype><code>MEDIATYPE_*</code></> constants in <tvar|defines><code>Defines.php</code></>.
<!--T:324-->
The syntax of the search is: <tvar|filetype><kbd>filetype:{type}</kbd></>. Example:
<!--T:325-->
<tvar|ftvideo><kbd>filetype:video</kbd></> - looks for all videos
<!--T:326-->
The filetype search is not case-sensitive.
=== filemime === <!--T:327-->
<!--T:447-->
Matches file MIME type. The syntax is:
<!--T:328-->
<tvar|filemime><kbd>filemime:{MIMEtype}</kbd></> - look for files of this MIME type
<!--T:329-->
The argument can be quoted to specify exact match. Without quotes, partial matches to components of MIME type will be accepted too.
<!--T:330-->
Examples:
<!--T:331-->
<tvar|fmimg><kbd>filemime:"image/png"</kbd></> - look for files with MIME type exactly <tvar|imgpng><code>image/png</code></>
<!--T:332-->
<tvar|fnpdf><kbd>filemime:pdf</kbd></> - look for all PDF documents
<!--T:333-->
The MIME type search is not case sensitive.
=== filesize === <!--T:334-->
<!--T:448-->
Search for file of given size, in kilobytes (kilobyte means 1024 bytes). The syntax is:
<!--T:335-->
<tvar|fsnum><kbd>filesize:{number}</kbd></> or <tvar|fsgreater><kbd>filesize:>{number}</kbd></> - file with size at least given number
<!--T:336-->
<tvar|fsless><kbd>filesize:<{number}</kbd></> - file with size no more than given number
<!--T:337-->
<tvar|fsbetween><kbd>filesize:{number},{number}</kbd></> - file with size between given numbers
<!--T:338-->
Examples:
<!--T:339-->
<tvar|fs20><kbd>filesize:>20</kbd></> or <tvar|fseq20><kbd>filesize:20</kbd></> - files 20KB and bigger
<!--T:340-->
<tvar|fsless1024><kbd>filesize:<1024</kbd></> - files smaller than 1MB
<!--T:341-->
<tvar|fs100k><kbd>filesize:100,500</kbd></> - files with sizes between 100KB and 500KB
=== File measures === <!--T:342-->
<!--T:446-->
It is possible to search for specific file measures: width, height, resolution (which is defined as square root of height × width), and bit depth. Not all files may have these properties. The syntax is:
<!--T:343-->
<tvar|mn><kbd>{measure}:{number}</kbd></> - file with measure that equals to given number
<!--T:344-->
<tvar|mng><kbd>{measure}:>{number}</kbd></> - file with measure that is at least given number
<!--T:345-->
<tvar|mnl><kbd>{measure}:<{number}</kbd></> - file with measure that is no more than given number
<!--T:346-->
<tvar|mnn><kbd>{measure}:{number},{number}</kbd></> - file with measure that is between given numbers
<!--T:347-->
Where <tvar|measure><code>measure</code></> can be:
<!--T:348-->
<tvar|filew1><kbd>filew</kbd></> or <tvar|filew2><kbd>filewidth</kbd></> - file width
<!--T:349-->
<tvar|fileh1><kbd>fileh</kbd></> or <tvar|fileh2><kbd>fileheight</kbd></> - file height
<!--T:350-->
<tvar|fres><kbd>fileres</kbd></> - file resolution (see above)
<!--T:351-->
<tvar|fbd><kbd>filebits</kbd></> - file bit depth
<!--T:352-->
Examples:
<!--T:353-->
<tvar|fw800><kbd>filew:>800 fileh:>600</kbd></> - files that are at least 800x600 pixels in size
<!--T:354-->
<tvar|fb16><kbd>filebits:16</kbd></> - files with 16-bit color depth
<!--T:355-->
<tvar|fh100k><kbd>fileheight:100,500</kbd></> - file between 100 and 500 pixels high
== Wikibase search == <!--T:484-->
<!--T:462-->
<tvar|1>{{ll|Extension:Wikibase|nsp=0}}</> extension defines some search keywords in order to make it easier to search for certain Wikibase items. Currently this is useful only on <tvar|2>{{ll|Wikidata}}</> sites.</translate>
<translate>
<!--T:485-->
See <tvar|1>{{ll|Help:WikibaseCirrusSearch}}</> for details.
== Cross-wiki search results == <!--T:444-->
<!--T:445-->
The search on Wikimedia projects includes [[<tvar|iwsearch>Special:MyLanguage/Cross-wiki Search Result Improvements</>|improved]] cross-wiki search results (also known as interwiki search results, sister projects search results).
</translate>
{{anchor|Explicit sort orders}}
<translate>
== Explicit sort orders == <!--T:474-->
<!--T:475-->
In addition to the default relevance based sort CirrusSearch can provide results a few other explicit sort orders.</translate>
<translate>
<!--T:476-->
Specifying a sorting order other than <tvar|1><code>relevance</code></> will disable all search keywords that effect scoring, such as <tvar|2><code>prefer-recent</code></> or <tvar|3><code>boost-templates</code></>.</translate>
<translate>
<!--T:477-->
The keywords will still be parsed, but they will have no effect.</translate>
<translate>
<!--T:478-->
Sorting options are currently available from the MediaWiki API by providing the <tvar|1><code>srsort</code></> parameter.</translate>
<translate>
<!--T:480-->
Sorting options can be manually added to a search URL by adding <tvar|1><code>&sort=''order''</code></>, for example <tvar|2>https://www.mediawiki.org/w/index.php?search=foo&sort=last_edit_desc</>.</translate>
<translate>
<!--T:479-->
Valid sort orders include:
</translate>
{| class="wikitable sortable"
!<translate><!--T:486--> Sort order</translate>
!<translate><!--T:487--> Description</translate>
|-
|incoming_links_asc
|<translate><!--T:488--> Lowest to highest number of incoming links.</translate> <translate><!--T:489--> This is approximately from least to most popular.</translate>
|-
|incoming_links_desc
|<translate><!--T:490--> Highest to lowest number of incoming links.</translate> <translate><!--T:491--> This is approximately from most to least popular.</translate>
|-
|last_edit_asc
|<translate><!--T:492--> From least recently to most recently edited</translate>
|-
|last_edit_desc
|<translate><!--T:493--> From most to least recently edited</translate>
|-
|create_timestamp_asc
|<translate><!--T:494--> From least to most recently created</translate>
|-
|create_timestamp_desc
|<translate><!--T:495--> From most to least recently created</translate>
|-
|just_match
|<translate><!--T:496--> A simple relevance sort based only on text matching</translate>
|-
|relevance
|<translate><!--T:497--> A relevance sort taking into account many features of the document</translate>
|-
|none
|<translate><!--T:498--> Unsorted, arbitrarily ordered lists.</translate> <translate><!--T:499--> Preferred for large result sets.</translate>
|}
<translate>
== Interface for advanced options == <!--T:457-->
<!--T:458-->
[[<tvar|image-asi>File:AdvSearch Screen 20170620.png</>|thumb|Advanced Search Interface]]
<!--T:459-->
The [[Extension:AdvancedSearch|AdvancedSearch]] extension adds an improved interface to the search page allowing the use of several options described above in a user-friendly manner. See [[<tvar|hlpadvsearch>Special:MyLanguage/Help:AdvancedSearch</>|here for the user manual]].
== See also == <!--T:49-->
</translate>
<translate>
<!--T:356-->
* {{<tvar|excc>ll|Extension:CirrusSearch</>}}
* [[<tvar|completion>Extension:CirrusSearch/CompletionSuggester</>|Completion Suggester]] - the incremental search feature of CirrusSearch
* [[<tvar|glossary>Wikimedia Discovery/Search/Glossary</>]] - definitions, context, and links for terms related to search.
* See  [[<tvar|oldsearch>Search/Old#Timeline</>]] for more on the development and debut of of CirrusSearch.
* See [[<tvar|helps>Help:Searching</>]] for MWSearch, used by the many wikis that don't have a search extension.
== External links == <!--T:357-->
<!--T:358-->
* [<tvar|lucene>http://lucene.apache.org/core/3_5_0/queryparsersyntax.html</> From Lucene], highly relevant documentation.
</translate>
* {{git file |file=tests/browser/features |project=mediawiki/extensions/CirrusSearch |text=<translate>
<!--T:50-->
Full specifications in the extension's browser tests</translate>}}
* [[Extension:CirrusSearch/Profiles]] - sets of tunable parameters that influence various aspect of the indexing
* [https://blog.wikimedia.org/c/technology/search/ Wikimedia blog articles related to search]
<translate>
== Notes and references == <!--T:359-->
</translate>
<references />
[[Category:Search{{#translation:}}]]
[[Category:Help{{#translation:}}]]

Latest revision as of 16:05, 30 May 2019