API:Page info in search results

It's useful to show users context when presenting Wikipedia search results.

When you search in the Wikipedia mobile apps, as you type they show a drop-down list of matching terms. They also show the lead image for the article and a description of it.

The lead image comes from Extension:PageImages, which adds a page_image property to pages giving its guess as to an appropriate image for the page. The description comes from Wikidata, which maintains a localized description of the subject of each wiki page.

A slow way to do this would be to query for pages matching what the user types, then make an API  request for the   property of the set of titles, and make another API query to wikidata.org requesting the Wikidata description. This works but involves multiple API queries.

How it works on Wikimedia wikis
Instead, WMF changed most wikis (but not, ) to load the basic extensions for accessing Wikidata. This allows you to query for  along with   on the source wiki, instead of making a second request to wwww.wikidata.org.

If you have a set of page titles, you can request their information all at once. Set  to the number of titles you're querying, otherwise it will only return one thumbnail from the first article in the set that has a plausible image. Also you should reduce the API response size by specifying only the properties you want from the API query modules, in this case only the the thumbnail and Wikidata description.

Querying query results in one request
This example is incomplete, since the set of page titless we're querying for properties – Albert Einstein||Albert Ellis|Albert Estopinal – must have come from another query.

You can improve this further by returning the properties you want directly from the initial query for a set of pages, using the MediaWiki API's generator feature. ... XXX

Further niceties
If the set of articles that start with what the user types does not fill the search results list, the Wikimedia mobile apps go on to search for in-page matches that you would get from Special:Search.

How it works in the MediaWiki code
When MediaWiki writes a change to the RecentChanges page, it also calls. The lets you configure different kinds of recent changes feeds, with different kinds of formatting. includes/rcfeed in core has their implementation. If you run a wiki of your own and would like to adapt these visualizations and monitors to it, you can enable similar feeds to a similar client that publishes changes over WebSockets or on an IRC channel. As usual, all aspects of WMF's setup are free and open source.

Going beyond
The Wikipedia mobile applications use face detection to show a better part of the image...

Alternatives
As an alternative, the Hovercards extension (Popups) uses the TextExtracts extension to show the lead information about an article from the local wiki.