CONSTRUCT/WHERE 中的 SPARQL 函数 [英] SPARQL functions in CONSTRUCT/WHERE
问题描述
我在处理查询时主要使用 SPARQL SELECT 以进行调试,但最后我想以 CONSTRUCT 方式使用最终结果;因为我想使用图表而不是键/值查询结果.
I mostly use SPARQL SELECT while working on a query for debugging purposes but in the end I want to use the final result it in a CONSTRUCT way; as I want to work with a graph and not key/value query results.
我还没有得到(并且似乎无法通过搜索引擎/文档找到)是我是否也可以以这种方式使用函数.例如,我使用属性路径将标题连接到超字符串"中,稍后我将使用它来构建 Lucene 索引以提高纯文本搜索质量:
What I don't get yet (and can't seem to find with search engines/docs) is if I can use functions as well that way. As an example, I use a property path to concatenate titles I get into a "superstring", which I later use for building a Lucene index to increase plain text search quality:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT (group_concat(?title ; separator = " ") AS ?fancytitle) WHERE {
GRAPH ?graph {
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> dc:relation+ ?relation .
?relation dc:title ?title .
}
}
现在我想拥有与新三元组相同的 ?fancytitle
Now I would like to have the same ?fancytitle
as a new triple like
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> <fancytitle> ?fancytitle .
所以我可以直接将它存储在一个新的图表中.这可能吗?我尝试了一些查询,但无法让 SPARQL 处理器接受它.仅供参考,我正在使用 Fuseki.
So I can store it directly in a new graph. Is this possible? I played with some queries but couldn't manage to get it accepted by the SPARQL processor. FYI I'm using Fuseki.
您可以在我的 SPARQL端点
推荐答案
在我同事的帮助下,我们得到了它的工作,UNION
和 GROUP BY
是必不可少的.此查询将图中所有 locah:ArchivalResource
的字符串放在一起:
With the help of my colleague we got it to work, UNION
and GROUP BY
are essential. This query puts the string together for all locah:ArchivalResource
in the graphs:
CONSTRUCT
{
?archresource skos:hiddenLabel ?supertitle
}
WHERE
{
SELECT ?archresource (group_concat(?title ; separator = ", ") AS ?supertitle) WHERE {
GRAPH ?graph {
{
SELECT ?title ?archresource WHERE {
GRAPH ?graph {
{
?archresource a locah:ArchivalResource ;
dc:title ?title .
} UNION
{
?archresource dc:relation+ ?relation .
?relation dc:title ?title .
}
}
}
}
}
} GROUP BY ?archresource
}
这篇关于CONSTRUCT/WHERE 中的 SPARQL 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!