MediaWiki's api.php search query module srnamespace parameter defaults to 0 instead of defaulting to site-wide default namespaces to be searched
Open, LowPublic

Description

We just had a bit of confusion in the #mediawiki IRC channel regarding this search: https://commons.wikimedia.org/w/api.php?action=query&list=search&srsearch=incategory:Mathematics (no results).

Compare with https://commons.wikimedia.org/wiki/Special:Search/incategory:Mathematics ("Results 1 - 20 of 313").

It looks like by default, srnamespace is set to 0 in the API (cf. https://commons.wikimedia.org/w/api.php?action=help&modules=query%2Bsearch --> "Default: 0"), so the expected search results are "missing." You need to do this query instead:

https://commons.wikimedia.org/w/api.php?action=query&list=search&srsearch=incategory:Mathematics&srnamespace=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|100|101|102|103|104|105|106|107|460|461|490|491|828|829|1198|1199|2300|2301|2302|2303|2600

Should srnamespace's implicit default vary based on which namespaces are searched by default on the wiki? I tend to think so.

MZMcBride updated the task description. (Show Details)
MZMcBride raised the priority of this task from to Needs Triage.
MZMcBride added a project: MediaWiki-API.
MZMcBride added a subscriber: MZMcBride.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptJan 19 2016, 5:24 AM

When filing T124009, I also thought maybe srnamespace could search all page namespaces by default and then specifying srnamespace would be used to narrow down the results to pages in a specific namespace.

Anomie added a subscriber: Anomie.Jan 19 2016, 3:39 PM

The difficulty with either of the suggestions here is that it would break backwards compatibility: all clients expecting the existing behavior of searching only the main namespace would unexpectedly start receiving results for other namespaces.

Anomie triaged this task as Low priority.
Anomie set Security to None.