-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Optimise SPARQL query for single entity metadata using wikibase:label #6376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… service - Use SERVICE wikibase:label for efficient retrieval of labels and descriptions in preferred language - Remove redundant label/description fetching logic - Prevent Cartesian product and improve query performance for
OPTIONAL {?item rdfs:label ?itemLabelAnyLanguage} | ||
BIND(COALESCE(?itemLabelPreferredLanguage, ?itemLabelAnyLanguage, "?") as ?label) | ||
# Get item label/class label/description in the preferred language of the user | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "${LANG},en". } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say my phone is in French and I am visiting Japan.
So, ${LANG} is fr
and most of the items around me only have labels in Japanese.
With this code, I do not see any label on most of the items, unfortunately (see screenshot).
A solution for this can be to append all possible Wikidata languages to that string. I will increase maintenance a bit as language codes are added/removed/modified from time to time, but that's a reasonable solution.
@nicolas-raoul I’ve added all assigned Wikidata languages to the label service for better coverage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a nit comment, otherwise working great! :-)
done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thanks! :-)
✅ Generated APK variants! |
Will check and create a new issue. |
Description (required)
Previously, super-popular items (e.g., Eiffel Tower) caused SPARQL query timeouts due to inefficient label and description fetching, resulting in grey pins and missing metadata in the app.
Fixes #6064
What changes did you make and why?
Optimized the SPARQL query for single entity metadata by using the wikibase:label service for efficient retrieval of labels and descriptions in the user's preferred language. Removed redundant label/description fetching logic to prevent Cartesian product and improve query performance, especially for super-popular items.
Tests performed (required)
Tested {build variant, ProdDebug} on {VIVO V25} with API level {35}.