Page MenuHomePhabricator

API wikilambdasearch_labels doesn't order the results by % of coincidence but by last updated
Closed, ResolvedPublic

Description

Because the results shown in the ZObjectSelector dropdown in the front-end are paginated, there might be the case in which an exact match doesn't show the correct result.

Steps to reproduce

{
	"Z1K1": "Z2",
	"Z2K1": {
		"Z1K1": "Z6",
		"Z6K1": "Z3"
	},
	"Z2K2": {
		"Z1K1": "Z4",
		"Z4K1": "Z3",
		"Z4K2": [
			"Z3",
			{
				"Z1K1": "Z3",
				"Z3K1": "Z4",
				"Z3K2": "Z3K1",
				"Z3K3": {
					"Z1K1": "Z12",
					"Z12K1": [
						"Z11",
						{
							"Z1K1": "Z11",
							"Z11K1": "Z1002",
							"Z11K2": "value type"
						}
					]
				}
			},
			{
				"Z1K1": "Z3",
				"Z3K1": "Z6",
				"Z3K2": "Z3K2",
				"Z3K3": {
					"Z1K1": "Z12",
					"Z12K1": [
						"Z11",
						{
							"Z1K1": "Z11",
							"Z11K1": "Z1002",
							"Z11K2": "key id"
						}
					]
				}
			},
			{
				"Z1K1": "Z3",
				"Z3K1": "Z12",
				"Z3K2": "Z3K3",
				"Z3K3": {
					"Z1K1": "Z12",
					"Z12K1": [
						"Z11",
						{
							"Z1K1": "Z11",
							"Z11K1": "Z1002",
							"Z11K2": "label"
						}
					]
				}
			}
		],
		"Z4K3": "Z103"
	},
	"Z2K3": {
		"Z1K1": "Z12",
		"Z12K1": [
			"Z11",
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1002",
				"Z11K2": "Key"
			},
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1003",
				"Z11K2": "Clave"
			},
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1004",
				"Z11K2": "Clé"
			},
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1430",
				"Z11K2": "Schlüssel"
			},
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1037",
				"Z11K2": "Chave"
			},
			{
				"Z1K1": "Z11",
				"Z11K1": "Z1314",
				"Z11K2": "Kodea"
			}
		]
	}
}
  • Also using the Sandbox, make a call to wikilambdasearch_labels with the exact match "Key" and language "en"

https://wikifunctions.beta.wmflabs.org/wiki/Special:ApiSandbox#action=query&format=json&list=wikilambdasearch_labels&wikilambdasearch_search=Key&wikilambdasearch_language=en

Observed behavior

  • The exact match "Key" doesn't appear until the end of the second page.

Expected behavior

  • If there's an exact match it should appear the first
  • Or there should be some kind of API parameter to determine how the results are being ordered, with an option of "best match"

Event Timeline

Change 964913 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Rewrite labels API and improve ZObjectSelector

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

Jdforrester-WMF changed the task status from Open to In Progress.Oct 10 2023, 2:17 PM
Jdforrester-WMF assigned this task to gengh.
Jdforrester-WMF moved this task from Backlog to In Progress on the Abstract Wikipedia team board.

Change 964913 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Rewrite labels API and improve ZObjectSelector

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

Etonkovidova changed the task status from In Progress to Open.Oct 12 2023, 12:47 AM
Etonkovidova subscribed.

Checked on beta - both API calls from the task description returns "Key" as the first matching result.

{
    "wikilambda_edit": {
        "success": true,
        "articleId": 5,
        "title": "Z3",
        "page": "Z3"
    }
}
"query": {
        "wikilambdasearch_labels": [
            {
                "page_id": 0,
                "page_is_redirect": false,
                "page_namespace": 0,
                "page_content_model": "zobject",
                "page_title": "Z3",
                "page_type": "Z4",
                "return_type": null,
                "match_label": "Key",
                "match_is_primary": "1",
                "match_lang": "Z1002",
                "match_rate": 1,
                "label": "Key",
                "type_label": "Type"
            },