Help:CirrusSearch

From MediaWiki.org
Jump to: navigation, search

Other languages:
العربية • ‎বাংলা • ‎català • ‎čeština • ‎Deutsch • ‎Zazaki • ‎Ελληνικά • ‎English • ‎Esperanto • ‎español • ‎فارسی • ‎suomi • ‎français • ‎עברית • ‎Bahasa Indonesia • ‎italiano • ‎日本語 • ‎한국어 • ‎Lëtzebuergesch • ‎македонски • ‎Nederlands • ‎occitan • ‎polski • ‎پښتو • ‎português • ‎português do Brasil • ‎русский • ‎Basa Sunda • ‎svenska • ‎தமிழ் • ‎Türkçe • ‎ئۇيغۇرچە • ‎українська • ‎ייִדיש • ‎中文

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. This page describes the features that are new or different compared to the past solutions.

Frequently asked questions

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

What's improved?

The new search engine features three main improvements over the old search engine, namely:

  • Better support for searching in different languages.
  • Faster updates to the search index, meaning changes to articles are reflected in search results much faster.
  • Expanding templates, meaning that all content from a template is now reflected in search results.

Updates

Updates to the search index are done in near real time. You should be able to search for your changes as soon as you make them. 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.

Search suggestions

The search suggestions you get when you type into the search box that drops down candidate pages is substantively the same with articles sorted by the number of incoming links. Worth noting is that if you start your search with ~ we won't find any articles as you type and you can safely hit enter at any time to jump to the search results page.

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

Full text search

Full text search (the kind that lands you on the search results page) searching in title, redirects, headings, and article text so it shouldn't present any surprises. The big change here is that templates are expanded.

Stemming

In search terminology, support for "stemming" means that a search for "swim" will also include "swimming" and "swimmed", but not "swam".

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.

Filters (intitle:, incategory: and linksto:)

New search- 6 months later.pdf

We've tightened up the syntax around these quite a bit.

  • intitle:foo
    • Find articles whose title contains foo. Stemming is enabled for foo.
  • intitle:"fine line"
    • Find articles whose title contains fine then line. Stemming is enabled. Matches The finest (lines) but not The finest ever lines.
  • 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.
  • intitle: foo bar
    • Syntax error, devolves into searching for articles whose title or text contains intitle:, foo, and bar.
  • incategory:Music
    • Find articles that are in Category:Music
  • incategory:"music history"
    • Find articles that are in Category:Music_history
  • incategory:"musicals" incategory:"1920"
    • Find articles that are in both Category:Musicals and Category:1920
  • -incategory:"musicals" incategory:"1920"
    • Find articles that are not in Category:Musicals but are in Category:1920
  • cow*
    • Find articles whose title or text contains words that start with cow
  • linksto:Help:CirrusSearch
    • find articles that link to a page
  • -linksto:Help:CirrusSearch CirrusSearch
    • find articles that mention CirrusSearch but do not link to the page 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:cow
    • Find articles in the content namespaces whose title starts with the word "cow".
  • domestic prefix:cow
    • Find articles in the content namespaces whose title starts with the word "cow" and that contain the word "domestic".
  • domestic prefix:Cow/
    • Find all sub-pages of the article "Cow" in the content namespaces that contain the word "domestic". This is a very common search and is frequently built using a special URL parameter called prefix=.
  • domestic prefix:Talk:Cow/
    • Find all sub-pages of the talk page "Talk:Cow" in the talk namespace that contain the word "domestic".
  • cow prefix:Pink Floyd/
    • Find all sub-pages of the article "Pink Floyd" in the content namespaces that contain the word "cow". The space is now insignificant.

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

Special prefixes

  • morelike:First article|Second article
    • Find articles whose text is most similar to the text of the given articles.
      • 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:
        • 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 (true|false): use only the field data. Defaults to false: the system will extract the content of the text field to build the query.
        • cirrusMltPercentTermsToMatch: The percentage of terms to match on. Defaults to 0.3 (30 percent).
        • Example: &cirrusMtlUseFields=yes&cirrusMltFields=title&cirrusMltMinTermFreq=1&cirrusMltMinDocFreq=1&cirrusMltMinWordLength=2
      • These settings can be made persistent by overriding cirrussearch-morelikethis-settings in Help:System message.
  • Talk:Foo
    • Find articles in the talk namespace whose title or text contains the word foo
  • File:foo
    • Find articles in the file namespace on this wiki and commons whose title or text contains the word
    • File:local:foo
      • You can add local: to the query (like File:local:foo) to remove the results from commons

Did you mean

"Did you mean" suggestions are designed to notice if you misspell an uncommon phrase that happens to be an article title. If so, they'll let you know. They also seem to suggest more things than they ought to sometimes.

Prefer phrase matches

If you don't have too much special syntax in your query we'll give perfect phrase matches a boost. I'm being intentionally vague because I'm not sure exactly what "too much special syntax" should be. Right now if you add any explicit phrases to your search we'll turn off this feature.

Fuzzy search

Putting a ~ after a search term (but not double quotes) activates fuzzy search. You can also put a number from 0 to 1 to control the "fuzziness" fraction, e.g. nigtmare~.9 or lighnin~.1 or lighnin~0.1. Closer to one is less fuzzy.

Phrase search and proximity

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 proper name for this "closeness" is "phrase slop". The default "phrase slop" is 1.

flowers algernon Flowers for Algernon flowers are for Algernon Flowers is a science fiction short story and subsequent novel for Algernon
"flowers algernon" YesY YesY N N
"flowers algernon"~1 YesY YesY N N
"flowers algernon"~2 YesY YesY YesY N
"flowers algernon"~0 YesY N N N
"flowers algernon"~10 YesY YesY YesY YesY

Quotes and exact matches

Quotes turn on exact term matches. You can add a ~ to the quote to go back to the more aggressive matcher you know and love.

flowers flower Flowers for Algernon flower for Algernon
flowers YesY YesY YesY YesY
"flowers" YesY N YesY N
"flowers"~ YesY YesY YesY YesY
"flowers algernon" N N YesY N
"flowers algernon"~ N N YesY YesY
"flowers algernon"~1 N N YesY N
"flowers algernon"~1~ N N YesY YesY

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>,<half_life_in_days>". proportion_of_score_to_scale must be a number between 0 and 1 inclusive. half_life_in_days must be greater than 0 but allows decimal points. This number works pretty well if very small. I've tested it around .0001, which is 8.64 seconds.

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

hastemplate:

You can find pages that use a certain template by adding the filter hastemplate: 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: hastemplate:"quality image", and for that same template name in the main namespace, this works hastemplate:":quality image". You can omit the quotes if the template title does not contain a space. -hastemplate:pagename 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:

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

File:boost-templates:"Template:Quality Image|200%" incategory:china
Find files in the China category sorting quality images first.
File:boost-templates:"Template:Quality Image|200% Template:Low Quality|50%" incategory:china
Find files in the China category sorting quality images first and low quality images last.
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 cirrussearch-boost-templates message this can be reduced to just popcorn.

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

A word of warning about cirrussearch-boost-templates: 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 brave new world would find a featured article with those words scattered throughout it instead of the article for 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 hastemplate:.

insource:

1.24
Gerrit change 137733

insource: searches wikitext. It has two flavors: one is delimited by /by slashes/:

insource:word and insource:"word1 word2"
These are like regular content search in that they are fast and case-insensitive, but they only recognize letters and numbers and spaces, and ignore the non-alphanumeric characters such as brackets, punctuation marks, or math symbols.
insource:/regexp/ and insource:/regexp/i
This can pick up template arguments, URLs, links, html etc. They are as thorough and precise as possible because they search wikitext by Regular expressions. They aren't efficient and we only allow a few of them to run at a time on the search cluster, but they are very powerful. The version with the extra i runs the expression case-insensitive, and is even less efficient.
Tip: Instead of running insource: searches directly, these return much much faster if they never run alone, but always alongside other items in the query to act as filters results, such as:
  • insource:self-absorbed insource:/self-absorbed/
  • word1 word2 insource:/self-absorbed/
  • intitle:blue insource:/self-absorbed/
  • insource:/self-absorbed/ prefix:User:Narcissa
To refine a regular expression search you should test it against target data on test pages. You can restrict it to subpages of your user page with:
  • insource:/regexp/ prefix:User:YourName/
To search for regular expression metacharacters literally, you must "escape" them, usually one at a time with a backslash \. You can also escape a set of characters in two ways using delimiters: double-quote-escape, and square-bracket escape. Inside these you can still backslash-escape the double-quote or square bracket characters: for example, "A literal \" character", or [-.\]]: which matches a literal dash, dot, or right square bracket. Since a forward slash delimits the entire regexp, you must always escape it inside the regexp. Inside a template, a regexp search for a pipe character is also template-escaped: the search box version of insource:/\|/ becomes the template version insource/\{{!}}/. For the metacharacters and there meanings see the explanation of the syntax. For the formal definition see the Lucene grammar for regular expressions.
For example, to find usage of a template called Val with an unnamed parameter of three to four digits having a possible minus sign and, on the same page, Val with a named argument "fmt=commas":
insource:/\{val\|[^}]*fmt=commas/ insource:/\{val\|-?[0-9]{3,4}[|}]/

Auxiliary text

Cirrus considers some text in the page to be "auxiliary" to what the page is actually about. Examples include table contents, image captions, and "This article is about the XYZ. For ZYX see ZYX" style links. You can also mark article text as auxiliary by adding the searchaux class to the html element containing the text.

Auxiliary text is worth less than the rest of the article text and it is in the snippet only if there are no main article snippets matching the search.

Lead text

Cirrus assumes that non-auxiliary text that is between the top of the page and the first heading is the "lead in" paragraph. Matches from the lead in paragraph are worth more in article ranking.

Commons search

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

See also