Page MenuHomePhabricator

Replace the Vector 2022 type-ahead search target with Wikidata entities, with links taking the user to the Abstract content for that Wikidata QID
Closed, ResolvedPublic

Description

description

Modify the existing Vector 2022 search integration to support Abstract Wikipedia mode by searching Wikidata entities (QIDs) instead of ZIDs, checking if abstract content exists, and providing appropriate redirects.

Current State

  • Vector 2022 search integration exists at resources/ext.wikilambda.languageselector/vector-2022SearchIntegration.js
  • Currently searches ZIDs using wikilambdasearch_labels API

Implementation Details

Backend/PHP: Should we create a new API endpoint for Wikidata entity search (ApiQueryWikidataEntities?)

Option 1:

  • Create wikilambdasearch_wikidata_entities
  • Use wbsearchentities (search for entities)
  • Accept search term, language, and limit parameters
  • T411716: Check if abstract content exists for each QID
  • T411716: Add hasAbstractContent flag for each result so frontend can make something:
    • little text underneath?
    • grey out?
    • cta next to articles that dont have abstract content; like [create] or similar
    • TBD

Option 2:

  • no new endpoint and query wikidata directly in vector-2022SearchIntegration.js
  • if mw.config.get( 'wgWikiLambdaEnableAbstractMode' ) is true, use Wikidata’s wbsearchentities instead of wikilambdasearch_labels.
  • Call Wikidata API from the client (e.g. fetch to https://www.wikidata.org/w/api.php with action=wbsearchentities, search, language, type=item, limit, etc.). Same idea as apiUtils.searchWikidataEntities
  • T411716: After receiving wbsearchentities results -> Check page existence with one local API ( like ApiUtils.fetchPageInfo) call per search OR Batch check page existence: one API call ( like ApiUtils.fetchPageInfo) per wbsearchentities request
  • T411716: Example when batching: Call the API ( like ApiUtils.fetchPageInfo) once per wbsearchentities response, passing all titles in one pipe-separated string: action=query, prop=info, titles=<title1>|<title2>|<title3>|...
  • T411716: After receiving wbsearchentities results and the page info-> determine what to show when a qid already has abstract content
    • We can do this asynchronously: e.g. show results first, then update with existence once the query returns, or await the query before returning the final list to the typeahead.

Frontend/JS: Vector 2022 search integration

  • Detect if Abstract mode is enabled (WikiLambdaEnableAbstractMode)
  • When in Abstract mode:
    • Use new wikilambdasearch_wikidata_entities API instead of wikilambdasearch_labels
    • Format/Transform results correctly
    • Show indicator for entities that already have abstract content (see previous #1)
    • Reuse the AbortController logic if needed.
    • Set URLs to:
      • Special:CreateAbstract/QID for entities without abstract content
      • Special:ViewAbstract/<language>/QID for entities with abstract content (or Special:ViewAbstract)

Apis

  1. wbsearchentities (client)
    • Endpoint: https://www.wikidata.org/w/api.php
    • Params: action=wbsearchentities, format=json, formatversion=2, search, language, uselang, type=item, limit, props=url (and optionally description/label props as needed). Add continue for loadMore if the typeahead supports it.
  2. Page existence (local, batched)
    • Same as fetchPageInfo: action=query, prop=info, titles=<ns>:Q1|<ns>:Q2|<ns>:Q3|... (all titles from one wbsearchentities response in one pipe-separated string), format=json, formatversion=2.
    • One request per wbsearchentities response: Batch all returned QIDs into a single titles parameter. The MediaWiki API supports querying many pages at once, so you make one local API call for every wbsearchentities call. (TBD)
    • Response: query.pages[] with title, missing (present if page does not exist). Use this to build a map/set of which QIDs have abstract content.

Event Timeline

DSmit-WMF changed the task status from Open to In Progress.Feb 17 2026, 2:46 PM
DSmit-WMF claimed this task.

Change #1240009 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Vector2022Search: Wikidata added and refactor the search module for Vector 2022

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

Hey @DSmit-WMF, could we close this one?

Patch isn't landed yet, so no. :-) But hopefully very soon!

Change #1240009 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Vector2022Search: Wikidata added and refactor the search module for Vector 2022

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