API talk:Search

From MediaWiki.org
Jump to navigation Jump to search

srredirects not working[edit]

Hi, it seems that srredirects is not recognized anymore as a parameter. For example, this request (https://fr.wikipedia.org/w/api.php?srprop=titlesnippet&srredirects=true&srlimit=max&action=query&list=search&format=xml&srnamespace=0&srsearch=intitle:"Liburn") returns a warning "Unrecognized parameter: 'srredirects'". --NicoV (talk) 15:43, 24 May 2014 (UTC)

This is removed in the new version.

Excluding redirects[edit]

not sure which genius thought this was a good idea:

redirects : Include redirect pages in the search. From 1.23 onwards, redirects are always included. (removed in 1.23)

I need to do a search that automatically excludes redirects, and it's now no longer possible. Why? — Preceding unsigned comment added by Hoggle42 (talkcontribs) 10:31, 23 October 2014‎

About template Search[edit]

I am wonder how I a search something like {{Example}}. When I search {{Example}}, the result shows as if I was search Example.

title search is disabled[edit]

Why I get this error code when I try to use srwhat=title param? For example here: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=wikipedia&srwhat=title&srprop=timestamp&continue= --Mladifilozof (talk) 19:25, 20 October 2015 (UTC)

I can't offer any insight into why CirrusSearch works the way it does, but based on the CirrusSearch help, it looks like you can leave srwhat blank and just use srsearch=intitle:wikipedia instead. That certainly appears to work, as you can see here. Robin Hood  (talk) 20:09, 20 October 2015 (UTC)
Thank you! --89.216.113.253 12:59, 22 October 2015 (UTC)

Limit[edit]

Hi there, it seem that there is an internal limit in the number of the search results which is 10000. How can i work around this? --Aschroet (talk) 17:52, 21 May 2017 (UTC)

Is the same also with search page. Bug or limit? --ValterVB (talk) 18:10, 2 September 2017 (UTC)
Having the same problem. Maxes out at 10000. -- GreenC (talk) 04:33, 3 October 2017 (UTC)

Phab T177270. -- GreenC (talk) 05:14, 3 October 2017 (UTC)

In case it helps, my not-particularly-clever workaround to this was to come up with a set of extra filters that partitioned the search space into chunks smaller than 10k. For example, say I wanted to get all the results for a search of "underneath" in Wikipedia articlespace (21,680 results). I would break that down into searches like:

  • underneath intitle:/[A-B]/ i.e. all results whose titles contain an uppercase A or B (9,101 results)
  • underneath intitle:/[C-J]/ -intitle:/[A-B]/ all results whose titles contain an uppercase letter from C to J, and don't have a capital A or B (8,843 results)
  • underneath -intitle:/[A-J]/ all results whose titles don't have an uppercase letter from A to J (3,736 results)

The above three queries exactly cover the results of the original query without overlapping (9,101 + 8,843 + 3,736 = 21,680). It requires some trial and error to identify sub-queries that come in under 10k. There might be a more elegant filter to use than intitle, but it was the best I could come up with. Colin M (talk) 16:22, 22 July 2019 (UTC)

Search Wikitext, not Rendered Page?[edit]

Can this search Wikitext, instead of Rendered Page? — Preceding unsigned comment added by Johnywhy (talkcontribs) 13:20, 3 June 2018 (UTC)

It's up to the underlying search engine. If you can do it via Special:Search, you can do the same via this API module. For Wikimedia wikis (or others using Extension:CirrusSearch), see Help:CirrusSearch#Insource. Anomie (talk) 13:25, 4 June 2018 (UTC)

API search list not showing pageid. How to configure return fields?[edit]

I'm using : MediaWiki 1.26.2 and SphinxSearch 0.9.0 <sphinxsearch-desc> trying : https://www.prf.gov.br/wikiprf/api.php?action=query&list=search&srsearch=suicide it's returning fields in search: ns, title, snippet, size, wordcount, timestamp, BUT NOT PAGEID or VERSIONID

How to configure search list parameters to return 'pageid' or 'versionid' to?

Apparently, the ability to return pageid wasn't added until MW 1.30 (which always returns it, no matter what), so it's not possible to get either pageid or revisionid from the search module in MW 1.26. You'd have to issue a separate command to get that information. Robin Hood  (talk) 21:54, 8 September 2018 (UTC)