SPARQL:从默认图和命名图中删除

问题描述 投票:1回答:1

使用AllegroGraph 6.4.6

我正在尝试根据定义的四边形生成单个DELETE查询:

// Example of dataset used for generation of SPARQL
const quads = [ 
  ['<1>','<2>','<3>'],        // Graph: DEFAULT
  ['<a>','<b>','<c>','<d>'],  // Graph: <d>
  ['<w>','<x>','<y>','<z>'],  // Graph: <z>
]

/* Example of triples being queried against

   S   P   O   G
  --- --- --- ---
  <1> <2> <3>
  <a> <b> <c> <d> 
  <w> <x> <y> <z>        If we delete <1> <2> <3>, we don't
  <1> <2> <3> <4>   <--  want to accidentally delete this quad   

*/

我能够生成SELECT查询以确定所有四边形的存在:

# Returns all specified quads that exist

SELECT ?s ?p ?o ?g
FROM DEFAULT 
FROM NAMED <d>
FROM NAMED <z>
WHERE {
  {
    ?s ?p ?o.
    VALUES (?s ?p ?o) {
      ( <1> <2> <3> )
    }
  }
  UNION
  {
    GRAPH ?g {?s ?p ?o.}
    VALUES (?s ?p ?o ?g) {
      ( <a> <b> <c> <d> )
      ( <w> <x> <y> <z> )
    }
  }
}
  • 返回VALUES中指定的所有四边形>
  • <1> <2> <3> <4>未返回。

  • 下一个查询是尝试创建DELETE查询,但是有一些问题(请注意Option 1

Option 2注释):
# Should delete all quads specified in VALUES

DELETE { 
  GRAPH ?g {?s ?p ?o.} 
  ?sD ?pD ?oD. 
}
# USING DEFAULT     # Option 1
# USING NAMED <d>   # Option 2
# USING NAMED <z>   # Option 2
WHERE {
  {
    ?sD ?pD ?oD.
    VALUES (?sD ?pD ?oD) {
      ( <1> <2> <3> )
    }
  }
  UNION
  {
    GRAPH ?g {?s ?p ?o.}
    VALUES (?s ?p ?o ?g) {
      ( <a> <b> <c> <d> )
      ( <w> <x> <y> <z> )
    }
  }
}
  • 仅使用Option 1注释,将返回错误消息:

    Found DEFAULT. Was expecting one of: NAMED, Q_IRI_REF, QNAME, QNAME_NS.
    
  • 仅使用选项2

  • 取消注释,仅删除指定的命名图三元组:
DELETED:

 S   P   O   G
--- --- --- ---
<a> <b> <c> <d>
<w> <x> <y> <z>
  • 同时带有选项1

  • 选项2的注释,每个三元组都会被删除,甚至我们不打算删除的三元组<1> <2> <3> <4>
    DELETED:
    
     S   P   O   G
    --- --- --- ---
    <1> <2> <3>
    <a> <b> <c> <d>
    <w> <x> <y> <z>
    <1> <2> <3> <4>
    

    使用AllegroGraph 6.4.6,我正在尝试针对定义的四边形生成单个DELETE查询://用于生成SPARQL const quads的数据集示例= [['<1>','<2>', '&...

    sparql allegrograph named-graphs
    1个回答
    1
    投票

    [FROM DEFAULT表示默认图形不是标准的SPARQL功能,因此其行为将取决于您使用的三元存储(并且许多SPARQL引擎只会给出语法错误)。

    © www.soinside.com 2019 - 2024. All rights reserved.