简体   繁体   English

在 Neptune 的 SPARQL 删除查询中使用限制

[英]using limit in Neptune's SPARQL Delete queries

I am trying to run this query in Amazon Neptune:我正在尝试在 Amazon Neptune 中运行此查询:

Delete{?s <http://mydomain#aresource> ?o.
          } 
WHERE {
    
    GRAPH ?g {
    
        ?s <http://mydomain#aresource> ?o.
        
    } 
} limit 1

But I'm getting this error:但我收到了这个错误:

"code": "MalformedQueryException",
"detailedMessage": "Malformed query: Encountered \" \"limit\" \"limit \"\" at line ..., column ....\nWas expecting one of:\n    <EOF> \n    \";\" ...\n    "

When I remove the limit, the query works.当我删除限制时,查询有效。 Does this mean that Neptune delete does not support the limit or am I doing something wrong?这是否意味着 Neptune delete 不支持限制或者我做错了什么?

I am not an expert at interpreting the SPARQL grammar, but I don't believe LIMIT on a DELETE WHERE clause is valid.我不是解释 SPARQL 语法的专家,但我不相信 DELETE WHERE 子句上的 LIMIT 是有效的。 However, the following query will achieve what I believe you are looking for...但是,以下查询将实现我相信您正在寻找的...

DELETE {
    ?s <http://mydomain#aresource> ?o.
} 
WHERE {    
    SELECT ?s ?o WHERE {
        GRAPH ?g {
            ?s <http://mydomain#aresource> ?o.        
        } 
    } LIMIT 1
} 

To prove this, I ran the following sequence of commands in Neptune.为了证明这一点,我在 Neptune 中运行了以下命令序列。

First,第一的,

INSERT DATA {
<http://test/a> <http://mydomain#aresource> <http://test/b> .
<http://test/c> <http://mydomain#aresource> <http://test/d> .
<http://test/e> <http://mydomain#aresource> <http://test/f> .
}

Then the DELETE WHERE query above.然后是上面的 DELETE WHERE 查询。 Finally,最后,

SELECT ?s ?o WHERE {?s <http://mydomain#aresource> ?o.}

and received the output |?s |?p |并收到 output |?s |?p | |-------------|-------------| |-------------|-------------| |http://test/c|http://test/d| |http://test/c|http://test/d| |http://test/e|http://test/f| |http://test/e|http://test/f|

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM