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
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.