module MediaWiktory::Wikipedia::Modules::Search

Perform a full text search.

The “submodule” (MediaWiki API term) is included in action after setting some param, providing additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and its submodules):

“`ruby api.query # returns Actions::Query

.prop(:revisions)  # adds prop=revisions to action URL, and includes Modules::Revisions into action
.limit(10)         # method of Modules::Revisions, adds rvlimit=10 to URL

“`

All submodule's parameters are documented as its public methods, see below.

Public Instance Methods

_info(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/modules/search.rb, line 93
def _info(value)
  defined?(super) && super || ["totalhits", "suggestion", "rewrittenquery"].include?(value.to_s) && merge(srinfo: value.to_s, replace: false)
end
_namespace(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/modules/search.rb, line 38
def _namespace(value)
  defined?(super) && super || ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "446", "447", "710", "711", "828", "829", "2300", "2301", "2302", "2303"].include?(value.to_s) && merge(srnamespace: value.to_s, replace: false)
end
_prop(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/modules/search.rb, line 106
def _prop(value)
  defined?(super) && super || ["size", "wordcount", "timestamp", "snippet", "titlesnippet", "redirecttitle", "redirectsnippet", "sectiontitle", "sectionsnippet", "isfilematch", "categorysnippet", "score", "hasrelated"].include?(value.to_s) && merge(srprop: value.to_s, replace: false)
end
_qiprofile(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/modules/search.rb, line 67
def _qiprofile(value)
  defined?(super) && super || ["classic", "classic_noboostlinks", "empty", "wsum_inclinks", "wsum_inclinks_pv", "popular_inclinks_pv", "popular_inclinks"].include?(value.to_s) && merge(srqiprofile: value.to_s)
end
_what(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/modules/search.rb, line 80
def _what(value)
  defined?(super) && super || ["title", "text", "nearmatch"].include?(value.to_s) && merge(srwhat: value.to_s)
end
enablerewrites() click to toggle source

Enable internal query rewriting. Some search backends can rewrite the query into one its thinks gives better results, such as correcting spelling errors.

@return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 120
def enablerewrites()
  merge(srenablerewrites: 'true')
end
info(*values) click to toggle source

Which metadata to return.

@param values [Array<String>] Allowed values: “totalhits”, “suggestion”, “rewrittenquery”. @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 88
def info(*values)
  values.inject(self) { |res, val| res._info(val) or fail ArgumentError, "Unknown value for info: #{val}" }
end
interwiki() click to toggle source

Include interwiki results in the search, if available.

@return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 113
def interwiki()
  merge(srinterwiki: 'true')
end
limit(value) click to toggle source

How many total pages to return.

@param value [Integer, “max”] @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 46
def limit(value)
  merge(srlimit: value.to_s)
end
namespace(*values) click to toggle source

Search only within these namespaces.

@param values [Array<String>] Allowed values: “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12”, “13”, “14”, “15”, “100”, “101”, “108”, “109”, “118”, “119”, “446”, “447”, “710”, “711”, “828”, “829”, “2300”, “2301”, “2302”, “2303”. @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 33
def namespace(*values)
  values.inject(self) { |res, val| res._namespace(val) or fail ArgumentError, "Unknown value for namespace: #{val}" }
end
offset(value) click to toggle source

When more results are available, use this to continue.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 54
def offset(value)
  merge(sroffset: value.to_s)
end
prop(*values) click to toggle source

Which properties to return:

@param values [Array<String>] Allowed values: “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), “snippet” (Adds a parsed snippet of the page), “titlesnippet” (Adds a parsed snippet of the page title), “redirecttitle” (Adds the title of the matching redirect), “redirectsnippet” (Adds a parsed snippet of the redirect title), “sectiontitle” (Adds the title of the matching section), “sectionsnippet” (Adds a parsed snippet of the matching section title), “isfilematch” (Adds a boolean indicating if the search matched file content), “categorysnippet” (Adds a parsed snippet of the matching category), “score” (Deprecated and ignored), “hasrelated” (Deprecated and ignored). @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 101
def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end
qiprofile(value) click to toggle source

Query independent profile to use (affects ranking algorithm).

@param value [String] One of “classic” (Ranking based on the number of incoming links, some templates, article language and recency (templates/language/recency may not be activated on this wiki)), “classic_noboostlinks” (Ranking based on some templates, article language and recency when activated on this wiki), “empty” (Ranking based solely on query dependent features (for debug only)), “wsum_inclinks” (Weighted sum based on incoming links), “wsum_inclinks_pv” (Weighted sum based on incoming links and weekly pageviews), “popular_inclinks_pv” (Ranking based primarily on page views), “popular_inclinks” (Ranking based primarily on incoming link counts). @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 62
def qiprofile(value)
  _qiprofile(value) or fail ArgumentError, "Unknown value for qiprofile: #{value}"
end
what(value) click to toggle source

Which type of search to perform.

@param value [String] One of “title”, “text”, “nearmatch”. @return [self]

# File lib/mediawiktory/wikipedia/modules/search.rb, line 75
def what(value)
  _what(value) or fail ArgumentError, "Unknown value for what: #{value}"
end