Page MenuHomePhabricator

Reader searches for a title prefix
Closed, ResolvedPublic3 Estimated Story Points

Description

"As a Reader, I want to get a list of pages that have a particular title prefix, so that I can find a specific page quickly."

GET /search/title?q={search term}

Searches for pages in the main namespace by a text search term. Returns pages that match the term as a prefix in the title. Pages that are unreadable by the current user are not returned. This is the endpoint most useful for type-ahead search.

Request headers: none
Request body: none

Status:
200 – OK

Headers: none

Body: JSON
object including a single property, "pages".

pages: an array of pages in relevance order, as with search in the Web interface. Maximum of 50 results. Each page result includes:
id: id of the page
key: prefixed DB key of the page, like "Main_Page"
title: title for display, like "Main Page"

Event Timeline

"As a Reader, I want to get a list of pages that have a particular title prefix, so that I can find a specific page quickly."

Can we change that to say "...that match a particular title prefix"? Typeahead completion implemented in Cirrus does a lot more than exact prefix matches.

GET /search/title?q={search term}

Internally, title search and completion search are not the same thing. Do we want to expose this distinction? Maybe this should be GET /search/completion?

In the Action API "title suggestions" exists as action=query&list=prefixsearch, and a variation returning results compatible with the OpenSearch protocol Suggestions extension (used by things like browser search bars) is provided by action=opensearch. The latter already includes default caching (controlled by $wgSearchSuggestCacheExpiry).

The Action API can also specifically list pages in a namespace by prefix (as requested here, although probably not what's actually wanted) via action=query&list=allpages with the apprefix parameter.

An MW REST API endpoint for any of these might consider these existing APIs for ideas and even potential refactoring to share code.

WDoranWMF set the point value for this task to 3.Feb 28 2020, 5:07 PM

Change 583391 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] SearchHandler: add support for completion search

https://gerrit.wikimedia.org/r/583391

Change 583391 merged by jenkins-bot:
[mediawiki/core@master] SearchHandler: add support for completion search

https://gerrit.wikimedia.org/r/583391

@daniel The docs for this endpoint (Autocomplete page title) are ready for your review. Feel free to make corrections directly to the wiki page or add your feedback here or on the talk page.

@daniel The docs for this endpoint (Autocomplete page title) are ready for your review. Feel free to make corrections directly to the wiki page or add your feedback here or on the talk page.

I made some changes, see https://www.mediawiki.org/w/index.php?title=API:REST_API/Search&type=revision&diff=3764096&oldid=3763880&diffmode=source. Overall it looks really good, thanks!

Thanks, @daniel! I tried to simplify the intro sentence a bit while still keeping "matches": "Searches wiki page titles, and returns matches between the beginning of a title and the provided search terms."

I saw that article! 0_0

@daniel and @apaskulin, do you have more work to do on this task?

Documentation for this endpoint is complete, so there's no further work for me on this task.