API:Search

From MediaWiki.org
Jump to: navigation, search
Tools clipart.png This page is part of the MediaWiki API documentation.
MediaWiki API

Quick overview:

v · d · e
MediaWiki version: 1.11

Parameters[edit | edit source]

  • srinfo : What metadata to return. Possible values: totalhits, suggestion. (Default: totalhits|suggestion)
  • srlimit : How many total pages to return. No more than 50 (500 for bots) allowed. (Default: 10)
  • srnamespace: The namespace(s) to enumerate. No more than 50 (500 for bots) allowed. (Default: 0)
  • sroffset : Use this value to continue paging (returned by query).
  • srbackend : Class name of search backend to use (Default: $wgSearchType)
  • srprop : What properties to return. Possible values: size, wordcount, timestamp, score, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, hasrelated. (Default: size|wordcount|timestamp|snippet)
    • size : Adds the size of the page in bytes
    • wordcount : Adds the word count of the page
    • timestamp : Adds the timestamp of when the page was last edited
    • score : Adds the score (if any) from the search engine
    • snippet : Adds a parsed snippet of the page
    • titlesnippet : Adds a parsed snippet of the page title
    • redirectsnippet: Adds a parsed snippet of the redirect
    • redirecttitle : Adds a parsed snippet of the redirect title
    • sectionsnippet : Adds a parsed snippet of the matching section
    • sectiontitle : Adds a parsed snippet of the matching section title
    • hasrelated : Indicates whether a related search is available
  • redirects : Include redirect pages in the search. From 1.23 onwards, redirects are always included. (removed in 1.23)
  • srsearch : Search for all page titles (or content) that has this value.
  • srwhat: Search inside the text or titles. (Default: title (if search engine doesn't support title searches, such as Lucene which is used by Wikipedia, then srwhat=title falls back to text))
    • title : Search in page titles
    • text : Search in page text
    • nearmatch: Search for the exact title
Depending on which search backend is in use, how srsearch is interpreted may vary. On Wikimedia wikis which use Lucene search, see w:Help:Searching#Search_engine_features for information about the search syntax.

Error Codes[edit | edit source]

Result Meaning
nosearch The search parameter must be set.
This was param-search before 1.17
search-text-disabled text search is disabled.
search-title-disabled title search is disabled.
search-error search error has occurred.

Example[edit | edit source]

Show a list of 10 pages that contain the word 'wikipedia'

See also[edit | edit source]