Help:CirrusSearch/zh

CirrusSearch is a new search engine for MediaWiki. The Wikimedia Foundation migrated to CirrusSearch since it features key improvements over the previously used search engine, LuceneSearch. 该页将会说明新的功能或与旧版的差异.

常见问题
如果你的疑问并未得到解答，请在讨论页提问，热心用户将会为你解答.

作了哪些改进？
新搜索引擎较之于旧搜索引擎有三大改进，即：


 * 更好的支持以不同语言搜索.
 * 更快的更新搜索索引，即页面修改能更快在搜索引擎中显示出来.
 * Expanding templates, meaning that all content from a template is now reflected in search results.

更新
搜索结果的索引列表会被及时更新. 当你改变了关键字时，新的结果也能立即显示处理. 对模板的变更将会在数分钟内起作用. 由于采用任务调度模式来处理这些变更，所以实际情况可能略有不同. 对文章的编辑，即使不包含任何改变，也会强制系统进行刷新——所以正常情况下不要进行这样的操作. 你可以在改变输入内容时立即得到搜索结果. Changes to templates should take effect in articles that include the template in a few minutes. The templates changes use the job queue, so performance may vary. A null edit to the article will force the change through, but that shouldn't be required if everything is going well.

搜索建议
当你在搜索框中键入关键字时，下拉框提供的搜索建议的排列顺序与各词条所拥有的导入链接数有关. 如果你在关键词前加入“～”，将不会匹配任何词条. 同时，你可以随时按回车键进入搜索结果页.

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

全文搜索
全文搜索功能（类似“在结果页中查找”）会搜索网页标题、重定向链接、小标题以及正文，所以搜索结果相对稳定. 本次主要的改动在于模板的扩充.

Stemming
There is support for dozens of languages, but all languages are wanted. There is a list of currently supported languages at elasticsearch.org; see their documentation on contributing to submit requests or patches.

过滤器（intitle: 、incategory: 和linksto: ）


我们对以下这些搜索语法进行了强化：


 * intitle:foo
 * Find articles whose title contains foo. Stemming is enabled for foo.
 * intitle:"fine line"
 * Find articles whose title contains fine line. Stemming is disabled.
 * intitle:foo bar
 * Find articles whose title contains foo and whose title or text contains bar.
 * -intitle:foo bar
 * Find articles whose title does not contain foo and whose title or text contains bar.
 * incategory:Music
 * Find articles that are in Category:Music
 * incategory:"music history"
 * Find articles that are in Category:Music_history
 * incategory:"musicals" incategory:"1920"
 * 查找同时属于“Musicals”和“1920”分类的词条
 * -incategory:"musicals" incategory:"1920"
 * 查找属于“1920”分类，但不属于“musicals”的词条
 * cow*
 * 查找标题或正文中包含以“cow”开头词汇的词条
 * linksto:Help:CirrusSearch
 * 查找含有链接的词条
 * -linksto:Help:CirrusSearch CirrusSearch
 * 查找一篇包含“CirrusSearch”字样，但本身并不含有链接的词条Help:CirrusSearch

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

注意：“prefix：”仍然需要放在查询语句的末尾.

morelike:
The  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 Help:System message.
 * Find articles whose text is most similar to the text of the given articles.
 * Find articles about stinging insects.
 * Find templates about regex searching for template usage on the wiki.
 * Find articles about stinging insects.
 * Find templates about regex searching for template usage on the wiki.
 * Find templates about regex searching for template usage on the wiki.
 * : Minimum number of documents (per shard) that need a term for it to be considered.
 * : Maximum number of documents (per shard) that have a term for it to be considered.
 * : Maximum number of terms to be considered.
 * : Minimum number of times the term appears in the input to doc to be considered. For small fields this value should be 1.
 * : Minimal length of a term to be considered. Defaults to 0.
 * : The maximum word length above which words will be ignored. Defaults to unbounded (0).
 * (comma separated list of values): These are the fields to use. Allowed fields are,  ,  ,  ,   and.
 * ( | ): use only the field data. Defaults to : the system will extract the content of the   field to build the query.
 * : The percentage of terms to match on. Defaults to 0.3 (30 percent).
 * Example:

Namespace
A search domain consisting of one namespace, or "all", can be specified at the beginning of a query. Two or more namespaces may be set at the search results page, Special:Search, in the Advanced dialog. This can be set for the query, or for the user's default search domain. Enter a namespace name, or enter, or enter a colon    for mainspace.

Namespace aliases are accepted. For the File namespace,  is accepted.


 * Find articles in the Talk namespace whose title or text contains the word "foo".
 * Find articles in the File namespace on this wiki and commons whose title or text contains the word "foo".
 * Add  to the File namespace query to remove the results from commons.
 * Find articles in the File namespace on this wiki and commons whose title or text contains the word "foo".
 * Add  to the File namespace query to remove the results from commons.
 * Add  to the File namespace query to remove the results from commons.

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

您是想找
“您是想找”功能可以在用户出现拼写错误时提供搜索建议. 如果搜索词不寻常（可能是输入错误），它将会给予提示，同时给出可能的正确拼写形式.

优先短语匹配
如果你没有使用特定的语法，我们将尝试找出最佳匹配的短语. 我们会有意地做到“模糊”查询，因为我们无法确定究竟什么样的语法是“最准确的”（这取决于查询者的意图）. 如果你使用了任何显式的语法结构，这一功能将不会被启用.

模糊搜索
在搜索词后加上“～”表示启用模糊搜索. 你也可以用数字0-1来控制“模糊”程度，如“nightmare~.9”、“lighnin~.1”或“ighnin~0.1”，其中1表示最“精确”，9表示最“模糊”.

近似短语搜索
Surrounding some words with quotes declares that you are searching for those words close together. You can add a ~ and then a number after the second quote to control just how close you mean. The default "closeness" is zero. One means one extra word allowed, and so on. For more than two words in the phrase, the closeness equals the total number of extra words, provided that all the words are also in order left to right.

For the closeness value of words given in right to left order, count and discard all the extra words, then add twice the the total count of remaining words minus one (in other words, add twice the number of segments). For the full proximity algorithm, see Elastic Search.

An explicit AND is required between two phrases because of the "inner" quotation marks.

引用与精确匹配
一些情况下，您还可以点击浏览器中的‘后退’按钮返回到链接媒体查看器中图像的页面.

prefer-recent:
You can give recently edited articles a boost in the search results by adding "prefer-recent:" to the beginning of your search. By default this will scale 60% of the score exponentially with the time since the last edit, with a half life of 160 days. This can be modified like this: "prefer-recent:,". proportion_of_score_to_scale must be a number between 0 and 1 inclusive. half_life_in_days must be greater than 0 but allows decimal points. This number works pretty well if very small. I've tested it around .0001, which is 8.64 seconds.

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

hastemplate:
You can find pages that use a certain template by adding the filter  to the search. We provide for the usual "syntactic sugar" of template calls. This means the lenient pagename and fullpagename capitalization works, and the main namespace abbreviation, ":" works. For example to find which pages transclude Quality image the full search (in all your preferred namespaces) can be: , and for that same template name in the main namespace, this works. You can omit the quotes if the template title does not contain a space. will filter pages that do not contain that template.

For wikitext that calls a template directly, you can use insource:, but hastemplate: searches the "post-expansion inclusion", so hastemplate: can find a template acting only temporarily as a "secondary template" or "meta-template", which are seen in neither the source nor content, ( but only included as a helper to any other template producing the final content). All content from a template is now reflected in search results is still the relevant philosophy here.

boost-templates:
你可以根据所用模板不同来调整搜索结果的排列顺序，比如 ；或使用新语法 来设置默认选项（通过发送系统消息）. 会取代 的设置（如果后者已经被设置的话）. 这一语法很特别，但若使用得当则能简化搜索. 以下是一些例子：


 * 查找“China”分类下的文件，并将高质量的图片排列在最前.
 * 查找“China”分类下的文件，并将高质量的图片排列在最前.


 * 查找“China”分类下的文件，并将高质量的图片排列在最前、低质量的图片排列在最后.
 * 查找“China”分类下的文件，并将高质量的图片排列在最前、低质量的图片排列在最后.


 * 查找有关“popcorn”的文件，并将高质量的图片排列在最前、低质量的图片排列在最后. 通过使用 语法（消息），可以将这一搜索简化为.
 * 查找有关“popcorn”的文件，并将高质量的图片排列在最前、低质量的图片排列在最后. 通过使用 语法（消息），可以将这一搜索简化为.

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

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

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

insource:
This can pick up template arguments, URLs, links, html, etc. It has two forms, one is an indexed search, and the other is regex based.

Tip: Instead of running a bare insource:/regexp/, 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 develop a simple filter to generate the search domain for the regex engine to search:



Any search without a namespace or prefix searches your default search domain, settable at Special:Search. It is commonly reset by power users to All namespaces, but if this occurs for a bare regexp search, then on a large wiki it will probably incur an HTML timeout before completing the search.

A regex search actually scours each page character-by character. By contrast, an indexed search actually queries a few records from a database separate from the wiki, and provides nearly instant results. When using a regex, include other search terms to limit the regex search domain as much as possible. There are many search terms that use an index and so instantly provide a highly 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, incategory, and linksto are excellent filters.
 * "word1 word2 word3", with or without the quotation marks, are OK.
 * hastemplate: if it produces less than a few hundred thousand pages, is OK.
 * namespace: is practically useless, but may enable a slow regexp search to complete.

The prefix operator is especially useful with a { {FULLPAGENAME}} or a subdirectory argument. To develop a new regexp, or refine a complex regexp, use  in any edit box. Search terms that do not increase the efficiency of a regexp search are the page-scoring operators: morelike, boost-template, and prefer-recent.

Metacharacters
This section covers how to escape metacharacters. For the actual meaning of the metacharacters see the explanation of the syntax. For the formal definition see the Lucene grammar for regular expressions.

The use of a regexp to search for an exact string that includes non-alphanumeric characters is a basic search. It finds regular expression metacharacters literally by placing the entire regexp inside double quotation marks, which blindly "quotes" or "escapes" any possible metacharacters from their advanced search meaning. An advanced search usually escapes metacharacters one at a time with a backslash.

For example  matches a '2', a literal plus sign, another '2', an equals sign, a '4' and a literal dot, with one possible space character between each math term. The equals sign has no special, metacharacter meaning in CirrusSearch, and so need not be escaped, but its OK to escape or quote any character because it basically has no effect. An exact-string search usually "quotes" the regexp because this will neutralize all metacharacter meanings.

The square-bracket notation for creating your own character-class also escapes 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 can 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 character that is either a dash or a right square bracket or a dot:  or.

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



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

辅助文本
Cirrus Search将页面中的某些内容视为“辅助文本”，如表格内容、图片标题，以及诸如“这是一篇关于XYZ的文章. 有关ZYX，请参见”的链接. 可以通过在html中添加class属性 来将某一文本标记为辅助文本.

辅助文本与其余文本相比显得次要. 所以仅当其余的文段无法匹配的搜索词时，辅助文本才会显示在结果片段中.

开头文本
Cirrus Search假定介于页面标题和第一个小标题直接的非辅助文本为＂导语＂段落. ＂导语＂中的匹配结果将在很大程度上影响搜索结果的排列顺序.

Commons search
By default when the search contains the file namespace, Cirrus will search commons as well. You can disable this behavior by adding  to the search. If you are using a namespace prefix to select the namespace the syntax looks like. If you aren't using a namespace prefix to select the namespace then the syntax looks like.