You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

维基数据SPARQL查询:单语文本属性P1813过滤无结果问题排查

Why Your SPARQL Filter Isn't Returning Results

Hey there! Let's break down why adding that FILTER clause is causing your query to return no results, even though you know matching values exist.

The Root Issue

You mentioned that property wdt:P1813 (alias) is a monolingual text property. Unlike multilingual text properties in Wikidata, monolingual text values don't carry explicit language tags in the same way. When you use FILTER(?v1 = "GNU AGPL"@en), you're asking to match a string that has an explicit English language tag—but the monolingual text values for P1813 likely don't have this tag attached (or their language is set to an empty string, depending on how Wikidata stores them). That's why the equality check fails.

Fixes to Try

Here are a couple of simple adjustments to make your filter work:

  1. Remove the language tag from the string
    Since monolingual text doesn't rely on explicit language tags for matching, just compare the raw string:

    SELECT DISTINCT ?i ?iLabel ?v1 WHERE { 
      ?i wdt:P31 wd:Q7603. 
      ?i wdt:P1813 ?v1. 
      FILTER(?v1 = "GNU AGPL") 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]". } 
    } LIMIT 100
    
  2. Use the STR() function to extract the raw string
    If you want to be explicit about comparing the text content (ignoring any potential language metadata), wrap ?v1 in STR():

    SELECT DISTINCT ?i ?iLabel ?v1 WHERE { 
      ?i wdt:P31 wd:Q7603. 
      ?i wdt:P1813 ?v1. 
      FILTER(STR(?v1) = "GNU AGPL") 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]". } 
    } LIMIT 100
    
  3. Verify the language of your values first
    If you're still unsure, run a quick query to check what language (if any) is associated with the P1813 values:

    SELECT DISTINCT ?i ?iLabel ?v1 (LANG(?v1) AS ?valueLanguage) WHERE { 
      ?i wdt:P31 wd:Q7603. 
      ?i wdt:P1813 ?v1. 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]". } 
    } LIMIT 100
    

    For monolingual text properties, ?valueLanguage will often return an empty string, confirming why the @en tag was breaking your filter.

内容的提问来源于stack exchange,提问作者Keanu Paik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:11:22