Skip to main content

Handling queries with language tags in PoolParty instances using GraphDB

21/08/2025

In the version of GraphDB embedded in PoolParty 9.3 and later, the SPARQL function LANG(?value) returns two-part language tags in the recommended capitalization style using uppercase for the 'region' component, such as en-US, en-CA.

This behavior may cause existing SPARQL queries to break if they are not using the canonical capitalization style. We therefore recommend handling queries that include multi-part language tags in one of the following ways:

  1. Use canonical capitalization for the explicit language tags to match the values returned by the LANG() function.

    # Example
    FILTER(LANG(?o) IN ("hr", "hr-HR", "hr-Latn-HR"))
  2. Force the values returned by the LANG() function to lowercase.

    # Example
    FILTER(LCASE(LANG(?o)) IN ("fr", "fr-be"))
  3. Use the case-insensitive operator LANGMATCHES(), if appropriate. This operator matches all language tags that begin with its second argument.

    # For example, the following will match not only `fr` , but also `fr-CA,` `fr-FR`  and so on:
    FILTER(LANGMATCHES(LANG(?o), "fr"))

This behavior also affects queries PoolParty uses for auto-completion and search. Auto-complete queries that include multi-part language tags should therefore change the LANG(?var) operator to LCASE(LANG(?var)).

# Example
FILTER(regex(LCASE(str(?searchLabel)), '^%%%searchString%%%', 'i') && lang(?searchLabel)='%%%lang%%%'
# ... should be changed to:
FILTER(regex(LCASE(str(?searchLabel)), '^%%%searchString%%%', 'i') && LCASE(lang(?searchLabel))='%%%lang%%%'