Hi, I found that if I have items, the first one matching the alias is found, instead of a later one which matches the label. Example: Q1 Label=SomethingElse, Alias=ABC Q2 Label=ABC
Would it be possible to make Q2 appear first? This is most useful if I only ask for one entity, thus this would be the best match.
Thanks!
Cheers Miguel
Hey Miguel!
I found that if I have items, the first one matching the alias is found, instead of a later one which matches the label.
After checking back it turns out this is intentional. The relevant lines of source code for this are using the $termType parameter in TermSqlIndex::getMatchingTerms, see https://phabricator.wikimedia.org/diffusion/EWBA/browse/master/lib/includes/...
The search results from the "wb_terms" table are ordered by "weight". This "weight" is currently the maximum of the number of labels and number of sitelinks. Adding an other criteria would interfere with this in unpredictable ways. For example, when a user is searching for an alias he knows, he still expects the more relevant search result to be the first match. The ranking is not expected to change just because the user was searching for an alias.
In your case I assume the item you find first does have more labels or more sitelinks than the other.
Best Thiemo
wikidata-tech@lists.wikimedia.org