Make api nearmatch search work same as 'go' feature
authorErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 30 Apr 2015 23:59:49 +0000 (16:59 -0700)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 5 May 2015 20:31:17 +0000 (16:31 -0400)
The 'nearmatch' feature of the api is the same as the 'go' feature of on-wiki
search. This makes the nearmatch api feature return the same results as the user
would have gotten in 'go', bringing more parity between api and browser based
searching. Without this change asking for a nearmatch within a namespace fails.

Bug: T37719
Change-Id: I715326242b63c558572ce9bf69b70bd650c2bc95

includes/api/ApiQuerySearch.php

index c12630e..90af15a 100644 (file)
@@ -92,7 +92,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                } elseif ( $what == 'title' ) {
                        $matches = $search->searchTitle( $query );
                } elseif ( $what == 'nearmatch' ) {
-                       $matches = SearchEngine::getNearMatchResultSet( $query );
+                       // near matches must receive the user input as provided, otherwise
+                       // the near matches within namespaces are lost.
+                       $matches = SearchEngine::getNearMatchResultSet( $params['search'] );
                } else {
                        // We default to title searches; this is a terrible legacy
                        // of the way we initially set up the MySQL fulltext-based