Page MenuHomePhabricator

๐Ÿ”Ž๏ธ Create endpoint for simple item search
Closed, ResolvedPublic13 Estimated Story Points

Description

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

  • q - search term
  • language - language code

Response structure in pseudo-JSON

{
  "results": [
    {
      "id": "Q123",
      "label": "<LABEL in language>"
      "description": "<DESCRIPTION in language>"
    },
    ...
  ]
}

Response:

  • always respond with status code 200, even for an empty result list
  • deal with error handling (500) later

Not in scope:

  • validation (errors on invalid input) of language codes
  • including a matched data element in the response
  • no special treatment of haswbstatement etc "keywords". Pass them as-is
  • search results provided in an asynchronous response
  • no fallback language treatment of labels or descriptions in the search results

In scope:

  • "input sanitization" that existing functionality interacting with Cirrus search/ Elastic search should be included here
  • no hard dependency on Cirrus search extension -- the API should return no results/empty results list with no search backend. In other words, the first iteration does not have to do anything special when no Elastic search is there, but software should not "explode" (no code paths triggering exceptions etc)

Task Breakdown Notes

  • create OpenAPI specification
  • create use case with request and response objects
    • including unit tests
  • create RouteHandler that makes use of the use case
    • including end-to-end test and openapi validation test
  • look into sanitizing inputs to avoid potential elastic search failures (see wbsearchentities) --> leave out if not needed
  • deal with potential absence of the Cirrus search extension --> empty result

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptJan 7 2025, 2:24 PM
WMDE-leszek set the point value for this task to 13.Feb 4 2025, 11:28 AM
Silvan_WMDE renamed this task from Create endpoint for simple item search to ๐Ÿ”Ž๏ธ Create endpoint for simple item search .Feb 5 2025, 3:27 PM
Silvan_WMDE updated the task description. (Show Details)

Change #1127088 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] Search: Return null for empty labels and descriptions

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

Change #1127088 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Search: Return null for empty labels and descriptions

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