Page MenuHomePhabricator

๐Ÿ’ก Create simple item prefix search endpoint
Closed, ResolvedPublic21 Estimated Story Points

Description

GET [...]/rest.php/wikibase/v0/suggest/items?language=en&q=...
Request parameters (query parameters)

  • q - search term
  • language - language code

Response structure in pseudo-JSON

{
  "results": [
    {
      "id": "Q123",
      "display-label": {
        "language": "<language code of LABEL or ALIAS>",
        "value": "<LABEL or ALIAS of the matched Item/Property>"
      },
      "description": {
        "language": "<language code of DESCRIPTION>",
        "value": "<DESCRIPTION>"
      },
      "match": {
        "type": <"label" OR "alias">,
        "language": "<language code of LABEL or ALIAS>",
        "text": "<LABEL or ALIAS that matched the search query>"
      }
    },
    ...
  ]
}

Acceptance criteria:

  • consider labels and aliases in the search, same as in the other existing RESTful search
  • matching item/property when its ID is provided as the query works, same as in the other existing RESTful search
  • Basic functionality of language fallback and matched data are implemented
  • The only sophisticated functionality to be implemented will be pagination
  • Errors to be the same as in simple item search
  • URL matching i.e. matching item/property when its URL is provided as the query, same as in SimpleItemSearch

Task breakdown notes:

  • OpenAPI schema
  • create use case happy path with request and response objects
    • use the existing EntitySearchHelper prefix search implementation (works for both Cirrus- and sql-based search)
    • including unit tests
  • request validation
  • create RouteHandler that makes use of the use case + middlewares
    • including end-to-end test
  • handle ID/URL matches
  • openapi validation test
  • mark production ready

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptMar 7 2025, 9:17 AM
Silvan_WMDE set the point value for this task to 21.Apr 11 2025, 9:44 AM
Silvan_WMDE added a project: Story.
Dima_Koushha_WMDE renamed this task from Create simple item prefix search endpoint to ๐Ÿ’ก Create simple item prefix search endpoint .Jun 11 2025, 6:10 AM

its me again with prod verf. I was using https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/search/items?q=d&language=en

and the FIRST thing it showed me is the item "Earth" lol where it matched an alias in english and on the third result matched "D.W.Baby". It definitely shows better results in the UI when I start looking for "d" but I'm not a 100% certain if this is something we can control?