三元组的 QName (MarkLogic)
QName for Triples (MarkLogic)
我一直在尝试各种方法来从我的三元组访问纬度和经度 QName。我的三重数据的一个例子是
<?xml version="1.0" encoding="UTF-8"?>
<sem:triples xmlns:sem="http://marklogic.com/semantics">
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</sem:predicate>
<sem:object>http://www.opengis.net/gml/_Feature</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/2003/01/geo/wgs84_pos#lat</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#double">59.11666666666667</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/2003/01/geo/wgs84_pos#long</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#double">28.083333333333332</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.georss.org/georss/point</sem:predicate>
<sem:object xml:lang="en">59.11666666666667 28.083333333333332</sem:object>
</sem:triple>
</sem:triples>
SPARQL 的输出"DESCRIBE"
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
@prefix p2: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
<http://dbpedia.org/resource/Slantsy> <http://www.georss.org/georss/point> "59.11666666666667 28.083333333333332"@en ;
a <http://www.opengis.net/gml/_Feature> ;
p2:long "28.0833333333333"^^xs:double ;
p2:lat "59.1166666666667"^^xs:double .
我在这个帖子里看到过类似的案例
使用
访问 Qname 的位置
fn:QName("http://www.w3.org/2003/01/geo/wgs84_pos#", "lat")
因此,我尝试了类似的方法并使用
cts:search(/sem:triples,
cts:element-pair-geospatial-query(
xs:QName("sem:triples"),
fn:QName("http://www.w3.org/2001/01/geo/wgs84_pos#", "lat"),
fn:QName("http://www.w3.org/2001/01/geo/wgs84_pos#", "long"),
cts:circle(2000, cts:point(59,28)))
)
但是,我收到了一个似乎不正确的空查询。任何建议将不胜感激谢谢。
===更新===
终于按照grtjin的建议让它工作了。使用路径
添加了地理空间索引
/sem:triples/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object
并使用
查询
cts:search(fn:doc(),
cts:path-geospatial-query(
"/sem:triples/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object",
cts:circle(10, cts:point(59,28))
)
)
哪个有效,returns 正确的结果。
但是我也尝试使用
进行查询
cts:search(fn:doc()/sem:triples,
cts:path-geospatial-query(
"/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object",
cts:circle(10, cts:point(59,28))
)
)
尽管期望这会起作用,因为我应该使用指定的路径查询每个 sem:triples 项目以到达特定的经纬度点。相反,我收到了一个空查询。我是不是理解错了什么?
如果你能做到这一点就好了,但不幸的是元素对索引不能这样工作。
首先,子元素必须是指定祖先的直接子元素,这就是为什么它说的是父元素而不是祖先元素。
其次,您不能这样定位元素值。包含lat和long的元素都是sem:object
个元素。
我建议在包含点的对象上使用地理空间路径索引,而您恰好拥有该点。我认为这作为路径参考应该有效:
sem:triple[sem:predicate = "http://www.georss.org/georss/point"]/sem:object
HTH!
我一直在尝试各种方法来从我的三元组访问纬度和经度 QName。我的三重数据的一个例子是
<?xml version="1.0" encoding="UTF-8"?>
<sem:triples xmlns:sem="http://marklogic.com/semantics">
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</sem:predicate>
<sem:object>http://www.opengis.net/gml/_Feature</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/2003/01/geo/wgs84_pos#lat</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#double">59.11666666666667</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.w3.org/2003/01/geo/wgs84_pos#long</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#double">28.083333333333332</sem:object>
</sem:triple>
<sem:triple>
<sem:subject>http://dbpedia.org/resource/Slantsy</sem:subject>
<sem:predicate>http://www.georss.org/georss/point</sem:predicate>
<sem:object xml:lang="en">59.11666666666667 28.083333333333332</sem:object>
</sem:triple>
</sem:triples>
SPARQL 的输出"DESCRIBE"
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
@prefix p2: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
<http://dbpedia.org/resource/Slantsy> <http://www.georss.org/georss/point> "59.11666666666667 28.083333333333332"@en ;
a <http://www.opengis.net/gml/_Feature> ;
p2:long "28.0833333333333"^^xs:double ;
p2:lat "59.1166666666667"^^xs:double .
我在这个帖子里看到过类似的案例
使用
访问 Qname 的位置fn:QName("http://www.w3.org/2003/01/geo/wgs84_pos#", "lat")
因此,我尝试了类似的方法并使用
cts:search(/sem:triples,
cts:element-pair-geospatial-query(
xs:QName("sem:triples"),
fn:QName("http://www.w3.org/2001/01/geo/wgs84_pos#", "lat"),
fn:QName("http://www.w3.org/2001/01/geo/wgs84_pos#", "long"),
cts:circle(2000, cts:point(59,28)))
)
但是,我收到了一个似乎不正确的空查询。任何建议将不胜感激谢谢。
===更新=== 终于按照grtjin的建议让它工作了。使用路径
添加了地理空间索引/sem:triples/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object
并使用
查询cts:search(fn:doc(),
cts:path-geospatial-query(
"/sem:triples/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object",
cts:circle(10, cts:point(59,28))
)
)
哪个有效,returns 正确的结果。
但是我也尝试使用
进行查询cts:search(fn:doc()/sem:triples,
cts:path-geospatial-query(
"/sem:triple[sem:predicate = 'http://www.georss.org/georss/point']/sem:object",
cts:circle(10, cts:point(59,28))
)
)
尽管期望这会起作用,因为我应该使用指定的路径查询每个 sem:triples 项目以到达特定的经纬度点。相反,我收到了一个空查询。我是不是理解错了什么?
如果你能做到这一点就好了,但不幸的是元素对索引不能这样工作。
首先,子元素必须是指定祖先的直接子元素,这就是为什么它说的是父元素而不是祖先元素。
其次,您不能这样定位元素值。包含lat和long的元素都是sem:object
个元素。
我建议在包含点的对象上使用地理空间路径索引,而您恰好拥有该点。我认为这作为路径参考应该有效:
sem:triple[sem:predicate = "http://www.georss.org/georss/point"]/sem:object
HTH!