Page MenuHomePhabricator

[PrefixSearch] Namespace name part of prefix search query should not override given namespace id(s)
Closed, ResolvedPublic

Description

When type into the search field (on de.wp) 'Kategorie:Vorlage:I' (in en: Category:Template:I) I get suggestion for 'Vorlage:I' (in en: Template:I). The Category-namespace is ignored. The example category is named 'Kategorie:Vorlage:Infobox'.


Version: unspecified
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=52610

Details

Reference
bz22773

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:02 PM
bzimport set Reference to bz22773.
bzimport added a subscriber: Unknown Object (MLST).

This works on the special page prefixindex [[:de:Special:PrefixIndex/Kategorie:Vorlage:I]], but fails on the openSearchXML-Api with the namespace:
action=opensearch&format=xml&namespace=14&search=Vorlage:I

Changing to MWSearch, because it looks like a problem there or in LuceneSearch.

MWSearch implements Hook "PrefixSearchBackend" and return false, so override the default from MediaWiki, which work.

Renaming and moving bug.

Steps to reproduce:

  • Get a wiki with pages like "Category:Template:Foo" (namespace=14, title="Template:Foo")
  • Query open search namespace=14&prefix=Template:F
  • ApiOpenSearch detects "Template:" as a prefix and searches in that namespace, ignoring 14.

Source code to confirm:

  • ApiOpenSearch calls PrefixSearch [1]
  • PrefixSearch creates a Title object from search query, and calls getNamespace(). If it does not return NS_MAIN, it uses the namespace of that title object, thus overriding and ignoring the given namespace id to search in (line 29 of PrefixSearch.php)

See also bug 30323.

Krinkle

[1] http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/api/ApiOpenSearch.php?revision=92400&view=markup#l45
[2] http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PrefixSearch.php?revision=86255&view=markup#l24

Just brought this up on IRC. Seems it's not possible due to performance to query multiple namespaces in the same query because the index is on page_namespace,page_title. So that would mean that searching for "Foo" in namespace 0, 5 and 10 would likely only give results for the namespace 0 since it's ordered by namespace and then by page_title.

For it to make sense we'd have to do multiple queries (one for each of the wanted namespaces). Then in PHP combine them and sort them by page_title and then by namespacename (not namespace-id).

So prefix "Foo", with namespaces=0|2|4 would give:
['Foo', 'Abbawiki:Foo', 'User:Foobar']

switch to milestone, remove release tracking dep

Umherirrender claimed this task.

Seems to work with the actually used SearchBackend on dewiki