Help:CirrusSearch/zh

在维基项目寻找信息最快的方法是直接检索. 在每一页上都有一个框.

CirrusSearch是一个使用Elasticsearch，来在默认MediaWiki搜索上提高增强功能的MediaWiki扩展. 维基媒体基金会已在所有维基媒体项目上使用了CirrusSearch. 此页面叙述CirrusSearch的功能. 如果你的疑问并未得到解答，请在讨论页提问，热心用户将会为你解答.

更多有关MediaWiki扩展的信息，请参见.

工作原理
输入关键字或短语，然后按回车键或点击放大镜图标、搜索或 Go 按钮. 如果一个页面具有与您输入的标题相同的标题，您将会直接转到相关页面. 否则，它会搜索维基上所有页面，并展现和你搜索的内容相关的文章列表，或者提示你没有找到与关键字相关的页面.

如果你直接点击“”按钮而没有填写任何内容，你将到达“Special:Search”，其中为你提供了额外的搜索选项（在任何搜索结果页面中也可用）.

您可能会发现限制搜索特定名字空间中的页面很有用. 例如，只搜索   页面. 选中您本次需要搜索的名字空间.

新動態
CirrusSearch较之于默认的MediaWiki搜索三大改进，主要有：


 * 更好的支持以不同语言搜索.
 * 更快的更新搜索索引，即页面修改能更快在搜索引擎中显示出来.
 * 展开模板，即在一個模板中的全部内容也能被搜索引擎搜索到.

搜索索引的更新频率如何？
搜索索引的更新几乎是实时完成的. 你可以在改变输入内容时立即得到搜索结果. 对模板的变更将会在数分钟内对包含其的条目起作用. 由于采用任务调度模式来处理这些变更，所以实际情况可能略有不同. 对文章的编辑进行空编辑，也会强制系统进行刷新——所以正常情况下不要进行这样的操作.

搜索建议
当你在搜索框中键入关键字时，下拉框提供的搜索建议的排列顺序与各词条所拥有的导入链接数有关. 这需要视为到来的wiki链接数量、页面大小、外部链接数量、标头数量和重定向数量. 搜索建议可以跳过，并且查询将直接指向搜索结果页面. 在查询前面添加波浪符号 即可. 例如“~Frida Kahlo”. 搜索建议仍将悬赏，但任何时候敲击回车键将带您进入搜索结果页面.

Accent/diacritic folding is turned on for some languages; the details are language-specific.

全文搜索
「全文搜索」是「索引搜索」. 所有頁面被儲存在維基的資料庫內；所有非重定向頁的單詞被儲存在搜尋資料庫內，並實際上是對維基全文的索引. 每個可見單詞都被索引到能找到該單詞的頁面列表中，因此搜索單詞的速度與查找單個記錄的速度一樣快. 此外，对于措辞的任何变化，搜索索引在几秒钟内更新.

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.

现在已经支持了多种语言，但是我们希望能支持所有的语言. elasticsearch.org提供了現在支持的語言；查看貢獻文檔以提交請求或補丁. Third-party open-source libraries are also used to support additional languages not covered by Elasticsearch.

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).

搜索功能还包括：


 * 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. 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.

字词与修改
基本的搜索单词是一个单词或者「引号中的短语」. 搜索引擎将以下各项识别为一个「单词」： Details vary by language, especially for languages without spaces, but search typically recognizes a "word" to be:


 * 一串数字
 * 一串字母
 * 字母/数字转换中出现的子单词，例如 txt2regex
 * 用 camelCase 描述的复合词中的子单词.

一个"停止单词"是一个被忽略的单词（因为它太常见，或者其他原因）. The list of stop words is language-specific and not all languages support stop words. 給定的搜索詞與"內容"匹配(在頁面上呈現). 若要與 wikitext 匹配,請使用 insource 參數(請參閱下面的 章節). 每個搜索參數都有自己的索引,並按自己的方式解釋其給定術語.

在字、词组、参数之间留空格，并输入进参数，可以包含大量空格实例及“灰色空间字符”. “灰色空间字符”全部是非字母数字字符：$characters. "Greyspace characters" are all the non-alphanumeric characters ~!@#$%^&_+-={}|[]\:";'<>?,./ . A mixed string of greyspace characters and whitespace characters, is "greyspace", and is treated as one big word boundary. 灰色空間是索引的創建和查詢的解釋方式.

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

The modifiers are ~ * \? - " ! . 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 prefixed to the first term of a query guarantees search results instead of any possible navigation.
 * A wildcard character inside a word can be an (escaped) question mark \? for one character or an asterisk * character for zero or more characters.
 * Truth-logic can interpret AND and OR, but parameters cannot. Note that the AND and OR operators currently do not function in the traditional truth-logic manner! For details see more on logical operators.
 * Truth-logic understands - or ! 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 greyspace, camelCase, or txt2number hints:


 * given words-joined_by_greyspace(characters) or wordsJoinedByCamelCaseCharacters it finds words joined by ... characters, in their bare forms or greyspace forms.
 * txt2number will match  or.
 * Stop words are enabled for the edge cases (in the periphery) of a grey_space or camelCase phrase. An example using the, of , and a is that the_invisible_hand_of_a matches  within the text.

A "search instead" report is triggered when a universally unknown word is ignored in a phrase.

Each one of the following types of phrase-matching contains and widens the match-tolerances of the previous one:

Note that CamelCase matching is not enabled for all languages.
 * An "exact phrase" "in quotes" will tolerate (match with) greyspace. Given "exact_phrase" or "exact phrase" it matches.
 * A greyspace_phrase initiates stemming and stop word checks.
 * Given CamelCase it will additionally match, in all lowercase, because CirrusSearch is not case sensitive in matching.

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

请注意，所有词干都不区分大小写.

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

Given, CirrusSearch, when in an "exact phrase" context, (which includes the insource parameter context), will not match  ,  , or  , but will then only match.

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 camelcase matches camelCase because Search is not case sensitive, but camelCase matches 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 parser_function -"parser function" is the sum of the basic searches  and.

用数字查询，我们会发现：


 * Plan9 或 Plan_9 匹配任何: 、 、$planned9、 、.
 * "plan9" 僅符合 (大小寫不敏感)
 * Plan*9 匹配 或

The star * wildcard matches a string of letters and digits within a rendered word, but never the beginning character. One or more characters must precede the * character.


 * When * matches numbers, a 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" * is treated as a greyspace character and not a wild card character, so it delimits words.

The \? wildcard represents one letter or number; *\? is also accepted, but \?* is not recognized.

通配符用于基本单词，短语和内容搜索，也可以是（某些）高级正则表达式搜索的替代（稍后介绍）.

在单词或短语后面加上波形符号 ~ 字符可激活模糊搜索.


 * For a phrase it is termed a proximity search, because proximal words are tolerated to an approximate rather than exact phrase.
 * For example, "exact one two phrase"~2 matches.
 * 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 word~0.5 ( word~.5 ), where at most two letters can be found swapped, changed, or added, but never the first two letters.
 * For a proximity phrase, a large number can be used, but that is an "expensive" (slow) search.
 * For a word word~2 is most fuzzy with an edit distance of 2 (default), and word~1 is least fuzzy, and word~0 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 Elasticsearch slop.

一些情况下，您还可以点击浏览器中的「回到上一步」按钮返回到链接媒体查看器中图像的页面.

源代码搜索
源代码搜索（Insource）功能可被用于查找任何在页面上渲染的“文字”，但它主要用于查找您可能很难找到词——包含MediaWiki标记，在重定向以外的任何頁面上. 这个搜索词完全忽略灰色空间： insource: "state state autocollapse" 匹配.

insource补充了自己. 一方面，它立即对wikitext中的任何单词进行全文搜索. 另一方面，它可以处理任何字符串的正则表达式搜索. 正则表达式扫描给定页面列表中的所有文本字符；它们没有单词索引来加快速度，如果运行时间必须超过20秒，则进程被中断. 正则表达式最后运行，所以为了限制不必要的字符级扫描，你可以将它作为“子句”添加到查询中的索引搜索选择的页面列表（搜索域），并对每个正则表达式查询执行此操作. Regexes run last in a query, so to limit needless character-level scanning, every regex query should include other search terms to limit the number of documents that need to be scanned. Often the best candidate to add to the regex query insource:/arg/ is insource:arg, where arg is the same (and uses no wildcards).

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

Insource indexed-search and regexp-search roles are similar in many respects:


 * Both search wikitext only.
 * Neither finds things "sourced" by a transclusion.
 * Neither does stemmed, fuzzy, or proximity searches.
 * Both want the fewest results, and both work faster when accompanied by another clause.

But indexed searches all ignore greyspace; wildcards searches do not match greyspace, so regexes are the only way to find an exact string of any and all characters, for example a sequence of two spaces. Regexes 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 below.

前缀和名字空间
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).

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.

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. 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.

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.

A namespace term overrides the search bar, and a prefix term overrides a namespace.

Enter a namespace name, or enter, or enter a     colon for mainspace. 全部不包含文件（File）名字空间. 文件包括在Commons（例如PDF）中保存的媒体内容，这些内容都是索引和可搜索的.

当涉及到文件时，一个命名空间修饰符  有作用，否则它被忽略.

名字空间的别名也是被接受的.

As with search parameters, local and all must be lowercase. Namespaces names are case insensitive.

The prefix: parameter matches any number of first-characters of all pagenames in one namespace. When the first letters match a namespace name and colon, the search domain changes.

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.

For pagenames that match, their subpage titles match by definition.

The prefix parameter does not allow a space before a namespace, but allows whitespace before a pagename.

The prefix parameter goes at the end so that pagename characters may contain " quotation marks.

The 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 inlanguage parameter is a filter of it. (See the next section.)

从搜索索引中排除内容
Content can be excluded from the search index by adding. This will instruct CirrusSearch to ignore this content from the search index (see for more context).

Additionally content can be marked as auxiliary information by adding. 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.

过滤器
A filter will have multiple instances, or negated instances, or it can run as a standalone filtering a search domain. A query is formed as terms that filter a search domain.

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).

A namespace is a specified search domain but not a filter because a namespace will not run standalone. A prefix will negate so it is a filter. 以下搜索参数是过滤器，可能同時有多個項目.

Insource (covered above) is also a filter, but insource:/regexp/ is not a filter. Filters and all other search parameters are lowercase. (Namespaces are an exception, being case insensitive.)

在标题中和在分类中
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.
 * cow*
 * 搜尋標題或內文由cow開頭的頁面
 * intitle:foo
 * 查找标题包含foo的条目. 词干提取对foo启用.
 * intitle:"fine line"
 * Find articles whose title contains fine line. Stemming is disabled.
 * intitle:foo bar
 * 查找标题包含foo或包含bar的条目.
 * -intitle:foo bar
 * 查找标题既不包含“foo”、也不包含“bar”的词条.
 * incategory:Music
 * 查找属于“Music”分类的词条
 * incategory:"music history"
 * 查找属于“Music_history”分类的词条
 * incategory:"musicals" incategory:"1920"
 * 查找同时属于“Musicals”和“1920”分类的词条
 * -incategory:"musicals" incategory:"1920"
 * 查找属于“1920”分类，但不属于“musicals”的词条

Intitle and incategory are old search parameters. Incategory no longer searches any subcategory automatically, but you can now add multiple category pagenames manually.

Since Regular expression searches are supported for intitle:
 * intitle:/regex/, intitle:/regex/i

Everything written in the #Regular expression searches is also valid for these searches, including warnings.

Deepcategory
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 SPARQL Category service from WDQS. Keywords are deepcategory or deepcat. Example:


 * deepcat:"musicals"
 * Find articles that are in Category:Musicals or any of the subcategories.

The DeepCat gadget that previously implemented the parameter was sunsetted in January 2020.

Note that some deepcat searches return incomplete results. See bug for more details.

链接到
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]], even when they are made by a template. It does not find a link made by a URL, even if that URL is an internal wiki link.

To find all wikilinks to a "Help:Cirrus Search", if "Help:Searching" and "H:S" are redirects to it:
 * 1) linksto: "Help:Cirrus Search"
 * 2) linksto: Help:Searching
 * 3) linksto: H:S

finds articles that mention "CirrusSearch" but not in a wikilink.

有模板
You can specify template usage with. 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.)

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.


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

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.

在语言中
For installations with the Translate extension, inlanguage is important for highly refined searches and page counts.


 * inlanguage: 语言代码

will produce search results in that language only.

例如


 * 计数wiki上的所有日语页面
 * all: inlanguage: ja


 * 在帮助名字空间中过滤掉德语和西班牙语页面
 * help: -inlanguage: de -inlanguage: es


 * 忽略翻译，如果英语是基本语言，则添加
 * inlanguage:en

Contentmodel
The contentmodel: keyword allows to limit the search to pages of a specific content model. For possible models cf. Content handlers. E.g.:


 * 只查看JSON页面：
 * contentmodel:json

子页面属于
要查找子页面.
 * subpageof: 父页面

例如


 * 查找所有CirrusSearch的子页面.
 * subpageof:CirrusSearch


 * Use double quotes if the parent page contains spaces.


 * subpageof:"Requests for comment"

Articletopic
The articletopic: keyword allows filtering search results by topic. For possible topics see. E.g. articletopic:books will filter the search results to articles about books. articletopic:books|films will filter to articles about books or films. articletopic:books articletopic:films will filter to articles which are about both books and films.

Only mainspace articles belong into topics, and topics are only available on Wikipedias. Unlike other filters, articletopic also does page weighting: articles which are a stronger match for a topic will be higher in the search results (while articles which aren't about that subject at all will be removed from the result set completely).

Topic models are derived via machine learning from ORES. Any given article receives a score on dozens of different topics, and therefore may appear under different keywords. For instance, the article on Albert Einstein may appear as a "physics" article and a "biography" article. All Wikipedias have scores available -- some have local-language topic models that have coverage on all articles. Other languages do not have local ORES models, and are using English-language scores assigned to articles in the local language that also exist in English Wikipedia. The languages with such "cross-wiki" scores do not have 100% coverage -- depending on the language, it may only be something like 60% of articles that have topics available.

Topic-related search data is updated weekly, so recently created articles might not show up in topic-based search queries.

Pageid
The pageid: keyword restricts search results to the given set of page IDs. This is not really useful for manual searching; it can be used by software tools for checking whether a set of pages match the given set of search conditions (e.g. for re-validating cached search results).

页面权重
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:page name 1|page name 2|...|page name n
 * 查找与给定文章的文本最接近类似的词条.
 * morelike:wasp|bee|ant
 * 查找有关昆虫叮咬的词条.
 * morelike:template:search|template:regex|template:usage
 * 查找在本wiki上在模板名字空間使用的有關regex的查找结果.

morelike is a "greedy" keyword, meaning that it cannot be combined with other search queries. If you want to use other search queries, use morelikethis in your search:


 * morelikethis:bee hastemplate:"featured article"
 * Find articles about bees that also have the "featured article" template.

The 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  in System message.
 * cirrusMltMinDocFreq : Minimum number of documents (per shard) that need a term for it to be considered.
 * cirrusMltMaxDocFreq : Maximum number of documents (per shard) that have a term for it to be considered.
 * cirrusMltMaxQueryTerms : Maximum number of terms to be considered.
 * cirrusMltMinTermFreq : Minimum number of times the term appears in the input to doc to be considered. For small fields ( title ) this value should be 1.
 * cirrusMltMinWordLength : Minimal length of a term to be considered. Defaults to 0.
 * cirrusMltMaxWordLength : The maximum word length above which words will be ignored. Defaults to unbounded (0).
 * cirrusMltFields (comma separated list of values): These are the fields to use. Allowed fields are title, text , auxiliary_text , opening_text , headings and all.
 * cirrusMltUseFields ( | ): use only the field data. Defaults to : the system will extract the content of the   field to build the query.
 * cirrusMltPercentTermsToMatch : The percentage of terms to match on. Defaults to 0.3 (30 percent).
 * Example:

Prefer-recent
Adding prefer-recent: anywhere in the query gives recently edited articles a slightly larger than normal boost in the page-ranking rules. Prefer-recent is only applied when using the default  sort order.

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 prefer-recent:0.6,160. This plays well with other page ranking rules, and is intended for most searches.

You can manipulate the rules: prefer-recent:boost,recent Technically "boost" is the proportion of score to scale, and "recent" is the half life in days. The boost is more than the usual multiplier, it is an exponential boost. The factor used in the exponent is the time since the last edit.

例如


 * prefer-recent:,7

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. For a simple "sort by date" in highly refined search results, where page ranking and boosting are largely meaningless, just boost the entire score.
 * prefer-recent:1,7 (weeks)
 * prefer-recent:1,1 (days)
 * prefer-recent:1,0.0007 (minutes)
 * prefer-recent:1,0.0001 (8.64 seconds)
 * prefer-recent:1,0.00001 (seconds)

推动-模板
你可以根据所用模板不同来调整搜索结果的排列顺序，比如 ；或使用新语法 来设置默认选项（通过发送系统消息）. 会取代 的设置（如果后者已经被设置的话）. 这一语法很特别，但若使用得当则能简化搜索. Like prefer-recent, boost-templates is only applied when using the default  sort order. Some examples:


 * File:boost-templates:"Template:Quality Image|200%" incategory:china
 * 查找中国分类下的文件，并将高质量的图片排列在最前.


 * File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" incategory:china
 * 查找中国分类下的文件，并将高质量的图片排列在最前、低质量的图片排列在最后.


 * 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  message this can be reduced to just.

不要在表示比例的百分数中添加小数点. 这样做不会起作用，而且搜索结果也不会有很大差别.

使用警告：如果你在排序比例中设置了一个非常大或非常小的值，全文搜索将会受到影响. 比如，将词条排序比例设置为100,000,000%，那么系统将会优先匹配每个单词所对应的文章，而不是搜索语句本身所匹配的文章；同时，语法匹配功能也无法起作用. 结果，类似 的搜索将会匹配全文中包含“brave”、“new”、“world”三个词的词条，而不是词条Brave New World.

正则表达式搜索
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.

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 develops a simple filter to generate the search domain for the regex engine to search (index based search domain marked bold, regexp part marked in italics):


 * insource:"debian.reproducible.net" insource:/debian\.reproducible\.net/
 * insource:"c:\program files (x86)" insource:/C\:\\Program Files \(x86\)/i
 * insource:" { {template}} " insource:/" { {template}}<"\/"tag>"/
 * insource:"[ [title|link label]]'s" insource:/"[ [title|link label]]'s"/
 * 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.

A query with no namespace specified and no prefix specified searches your default search domain, (settable on any search-results page, i.e. at 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 a 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 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:


 * insource:"" with quotation marks, duplicating the regexp except without the slashes or escape characters, is ideal.
 * intitle (without regex search), 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.

To test a bare regexp query you can create a page with test patterns, and then use the prefix parameter with that fullpagename. 匹配项会被高亮. It searches that page (in the database) and its subpages.

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

元字符
此节包含如何在regexp搜索中，避免元字符（metacharacters）的内容 For the actual meaning of the metacharacters see the explanation of the syntax.

例如：


 * 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.

You can start out intending an exact string search, but keep in mind:


 * 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.

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.


 * 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.

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.


 * instead of
 * is as good as
 * But  always.
 * And .  It finds the   literally, which is not the   you probably wanted.

Backslash-escape using insource:/regexp/ allows escaping the " and / delimiters, but requires taking into account metacharacters, and escaping any:


 * To match a  delimiter character use.
 * To match a  delimiter character use.
 * The escaped metacharacters would be.
 * The equivalent expression escaped with double-quotes is.

The simplest algorithm to create the basic string-finding expression using insource:/"regexp"/, need not take metacharacters into account except for the " and / characters:
 * 1) Write   out. (The /" delimiters "/ are not shown.)
 * 1) Replace   with   (previous double-quote: stop, concatenate, quote restart).
 * 1) Replace   with   (stop, concatenate, start).
 * 1) You get , 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:  or.

For general examples using metacharacters:


 * insource:"2+2=4" insource:/"2+2=4"/ matches "2 + 2 = 4", with zero spaces between the characters.
 * 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.
 * insource:"[ [link|2\3?]]\" insource:/"[ [link|2\3?]]< "\/" tag>"/

There are some notable differences from standard regex metacharacters:

To search for a string that contains a newline, you can do a search like  which means not a curly brace, then two curly braces, then any two characters except a curly brace, space, or pipe, then a  tag. The "any character except" will include a newline in the search. Note thas this search was designed only to match to the following string:
 * The  or   are not reserved for matching a newline.


 * 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   does, but without regard to the number of character positions, or the range in each position, so   works, and even   works.

Regex on titles
The insource keyword does only search the page source content. To run regex searches on the title strings intitle:/regex/ can be used.

高级示例
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  having any allowable spaces around it, (it could be the same template call, or a separate one):



Note that the = sign in "fmt commas" is not needed but that adding it would not change the search results. It is fast because it uses two filters so that every page the regexp crawls has the highest possible potential.

有界限
你可以將搜索的頁面限制在指定的地理坐標附近. 坐標可以使用<緯度>, <經度>的格式，也可以提供頁面標題來當作指定的坐標. 如果有需要，可以限制搜索範圍的距離. 例如： 示例：


 * neartitle:"San Francisco"
 * neartitle:"100km,San Francisco"
 * nearcoord:37.77666667,-122.39
 * nearcoord:42km,37.77666667,-122.39

已提高
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.


 * boost-neartitle:"San Francisco"
 * boost-neartitle:"100km,San Francisco"
 * boost-nearcoord:37.77666667,-122.39
 * boost-nearcoord:42km,37.77666667,-122.39

文件属性搜索
Since MediaWiki 1.28, CirrusSearch supports indexing and searching of properties of files in the  namespace. This includes:
 * file media type
 * MIME type
 * size
 * width & height
 * resolution
 * bit depth for files that support these

文件类型
文件類型搜索允許根據分類搜索文件，例如辦公室文件、影片、點陣圖、向量圖等. 目前存在以下類型：



This list may be extended in the future. See also  constants in.

The syntax of the search is: filetype:{type}. Example:

filetype:video - looks for all videos

The filetype search is not case-sensitive.

文件mime
Matches file MIME type. The syntax is:

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.

示例：


 * filemime:"image/png" - look for files with MIME type exactly
 * filemime:pdf - look for all PDF documents
 * -filemime:pdf - skip all PDF documents (notably on Commons)

The MIME type search is not case sensitive.

文件大小
搜索指定大小的文件，單位為千位元組（1024位元組）. 語法為：


 * filesize:{number} 或 filesize:>{number} - file with size at least given number
 * filesize:<{number} - file with size no more than given number
 * filesize:{number},{number} - file with size between given numbers

示例：


 * filesize:>20 或 filesize:20 - 至少20KB的文件
 * filesize:<1024 - 小于1MB的文件
 * filesize:100,500 - 大小在100KB到500KB之間的文件

文件度量
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:


 * {measure}:{number} - file with measure that equals to given number
 * {measure}:>{number} - file with measure that is at least given number
 * {measure}:<{number} - file with measure that is no more than given number
 * {measure}:{number},{number} - file with measure that is between given numbers

可以：

filew 或 filewidth — 文件宽度

fileh 或 fileheight — 文件高度

fileres — 文件解析度（見上方）

filebits — 文件位元深度

示例：

filew:>800 fileh:>600 — 大小至少為800x600像素的文件

filebits:16 — 有16位元顏色深度的文件

fileheight:100,500 — 文件高度在100到500像素之間

Wikibase搜尋
The extension defines some search keywords in order to make it easier to search for certain Wikibase items. This is useful on and other Wikibase sites, including to search for images with Structured data on Wikimedia Commons. 详情请见.

跨維基搜索結果
The search on Wikimedia projects includes improved cross-wiki search results (also known as interwiki search results, sister projects search results).

Explicit sort orders
In addition to the default relevance based sort CirrusSearch can provide results a few other explicit sort orders. Specifying a sorting order other than  will disable all search keywords that affect scoring, such as   or. The keywords will still be parsed, but they will have no effect.

Sorting options are currently available from the MediaWiki API by providing the  parameter.

Sorting options can be manually added to a search URL by adding, for example https://www.mediawiki.org/w/index.php?search=foo&sort=last_edit_desc.

Valid sort orders include:

用于高级选项的界面


The AdvancedSearch extension adds an improved interface to the search page allowing the use of several options described above in a user-friendly manner. See here for the user manual.

参见

 * Completion Suggester - the incremental search feature of CirrusSearch
 * Wikimedia Discovery/Search/Glossary - definitions, context, and links for terms related to search.
 * See Search/Old for more on the development and debut of of CirrusSearch.
 * See Help:Searching for MWSearch, used by the many wikis that don't have a search extension.

外部链接

 * From Lucene, highly relevant documentation.
 * (as of 2017-12-06)
 * Extension:CirrusSearch/Profiles – sets of tunable parameters that influence various aspect of the indexing
 * Wikimedia blog articles related to search