0

尝试从运行 GeoSPARQL 扩展的 Jena Fuseki 服务器中删除数据。

查询似乎无效。

尝试使用DELETEor时服务器的输出DELETE DATA是:

23:29:06 WARN  Fuseki     :: [2] Parse error: Encountered " "delete" "DELETE "" at line 15, column 1.
23:29:52 WARN  Fuseki     :: [4] Parse error: Encountered " <DELETE_DATA> "DELETE DATA "" at line 15, column 1.

从头开始运行服务器的命令,没有空索引和 tdb 文件:

java -jar jena-fuseki-geosparql-4.2.0.jar  \
  -rf file.n3 \
  --index_expiry 50000000000000,500000000000,500000000000 -p 3034 \
  -t ./geosparql-tdb2 \
  -t2 --update \
  --spatial_index ./geosparql-tdb2/spatial.index

( prefix spa: <http://jena.apache.org/spatial#>)

因此,删除查询是:

DELETE DATA { ?feature a sosa:featureOfInterest . }
WHERE {
  ?feature a sosa:featureOfInterest ;
  spa:withinBox(54.3 -116.5 34.2 -93.9) .
}

这对应于按预期工作的选择查询(即正确选择应删除的行):

select * WHERE {
  ?feature spa:withinBox(54.3 -116.5 34.2 -93.9) .
}

有任何想法吗?

编辑: 导致解析错误的删除查询不正确。这个新的删除查询不会导致错误。但是,这仍然不会删除数据。

DELETE {
  ?g a geo:Geometry .
}
WHERE {
  ?g a geo:Geometry .
  ?g spa:withinBox(54.3 -116.5 34.2 -93.9) .
}

此外,查询 URL 是/ds/query,删除 URL 是/ds/update

最后,请求在python中执行如下:

def run_sparql(s, qtype='query'):
  url = 'http://localhost:3034/ds/' + qtype
  payload = s
  headers = {'Content-Type': 'application/sparql-query'}
  res = requests.post(url, data=payload, headers=headers)

查询的响应代码delete415while 对于 select 它是200

编辑#2: 将内容类型从更改application/sparql-queryapplication/sparql-update导致状态代码为400,但仍不会按预期删除数据。

要清楚:

s = '''
prefix geo: <http://www.opengis.net/ont/geosparql#> 
prefix spa: <http://jena.apache.org/spatial#>
DELETE {
  ?g a geo:Geometry .
}
WHERE {
  ?g a geo:Geometry .
  ?g spa:withinBox(54.3 -116.5 34.2 -93.9) .
}
'''

url = 'http://localhost:3034/ds/update'
payload = s
headers = {'Content-Type': 'application/sparql-update'}
res = requests.post(url, data=payload, headers=headers)

即使这样也行不通:

prefix geo: <http://www.opengis.net/ont/geosparql#> 
DELETE {?g a geo:Geometry}
4

0 回答 0