Module: MediaWiki::Query::Lists::Search
- Included in:
- MediaWiki::Query::Lists
- Defined in:
- lib/mediawiki/query/lists/search.rb
Instance Method Summary collapse
-
#get_prefix_search(prefix, limit = 100) ⇒ Array<String>
Searches the wiki by a prefix.
-
#get_search_result_amount(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) ⇒ Integer
Gets the amount of results for the search value.
-
#get_search_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) ⇒ Array<String>
Gets an array containing page titles that matched the search.
-
#get_search_text_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN'], limit = @query_limit_default) ⇒ Array<String>
Searches page contents, returns an array containing page titles whose content matched the search.
Instance Method Details
#get_prefix_search(prefix, limit = 100) ⇒ Array<String>
Searches the wiki by a prefix. one of the methods that does not use the query_limit_default attribute.
62 63 64 65 66 67 68 69 70 |
# File 'lib/mediawiki/query/lists/search.rb', line 62 def get_prefix_search(prefix, limit = 100) params = { list: 'prefixsearch', pssearch: prefix, pslimit: get_limited(limit, 100, 200) } query_ary(params, 'prefixsearch', 'title') end |
#get_search_result_amount(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) ⇒ Integer
Gets the amount of results for the search value.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mediawiki/query/lists/search.rb', line 10 def get_search_result_amount(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) params = { action: 'query', list: 'search', srsearch: search_value, srnamespace: validate_namespace(namespace) } response = post(params) response['query']['searchinfo']['totalhits'] end |
#get_search_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) ⇒ Array<String>
Gets an array containing page titles that matched the search.
28 29 30 31 32 33 34 35 36 |
# File 'lib/mediawiki/query/lists/search.rb', line 28 def get_search_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN']) params = { list: 'search', srsearch: search_value, srnamespace: validate_namespace(namespace) } query_ary(params, 'search', 'title') end |
#get_search_text_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN'], limit = @query_limit_default) ⇒ Array<String>
Searches page contents, returns an array containing page titles whose content matched the search.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mediawiki/query/lists/search.rb', line 43 def get_search_text_results(search_value, namespace = MediaWiki::Constants::NAMESPACES['MAIN'], limit = @query_limit_default) params = { list: 'search', srsearch: search_value, srwhat: 'text', srlimit: get_limited(limit), srnamespace: validate_namespace(namespace) } query_ary(params, 'search', 'title') end |