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

如何修正SPARQL查询以获取含‘human’与‘peace’的诺贝尔奖奖项

Fixing Blazegraph Full-Text Search SPARQL Query for Nobel Prize Data

Let's break down why your original query is failing and how to fix it to get the results you want:

The Problem with Your Original Query

Blazegraph's bds:search isn't meant to be used as a function inside a FILTER clause. That syntax doesn't align with how Blazegraph handles full-text search—instead, you need to define the search using triple patterns to specify the target property and search terms.

Corrected Queries

Here are two valid approaches to achieve your goal:

Approach 1: Directly Annotate the Target Variable

This is the more concise way, applying the search directly to the ?description variable that holds the motivation text:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bds: <http://www.bigdata.com/rdf/search#>
PREFIX nobel: <http://data.nobelprize.org/terms/>

SELECT ?awards ?description WHERE {
  ?entity rdfs:label ?awards .
  ?entity nobel:motivation ?description .
  
  # Search for entries containing both "human" and "peace" in the motivation
  ?description bds:search '"human" AND "peace"' .
  # Optional: Ensure all terms are matched (redundant with AND, but explicit)
  ?description bds:matchAllTerms true .
}

Approach 2: Configure Search via bds:search Subject

If you prefer a more explicit configuration, you can use the bds:search special subject to define your search parameters:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bds: <http://www.bigdata.com/rdf/search#>
PREFIX nobel: <http://data.nobelprize.org/terms/>

SELECT ?awards ?description WHERE {
  ?entity rdfs:label ?awards .
  ?entity nobel:motivation ?description .
  
  # Define the full-text search parameters
  bds:search bds:searchPredicate nobel:motivation .
  bds:search bds:searchText '"human" AND "peace"' .
  bds:search bds:matchAllTerms true .
}

Key Notes

  • The "human" AND "peace" syntax ensures both terms are present in the nobel:motivation field. If you wanted to match the exact phrase "human peace", you'd use that instead.
  • bds:matchAllTerms true explicitly enforces that all search terms are found—while the AND operator already does this, adding it makes your intent clearer.
  • Both queries will return award labels (?awards) and their corresponding motivation descriptions that meet your full-text criteria.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 07:46:42