地理空间查询与光学API(MarkLogic)(Geospatial Queries with Op

2019-10-31 10:20发布

从带过来问线程 。我是目前正在努力做SPARQL和CTS使用光学API进行搜索。 我曾尝试使用下面的代码来尝试

查询中使用

import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
let $people := op:from-lexicons(
  map:entry("people",cts:uri-reference()),
  "lexicon"
)=>op:where(
     cts:path-geospatial-query("people_data/location",
    cts:circle(7500, cts:point(89.39101918779838, 51.97989163203445)),
    "type=long-lat-point")
  )

let $questions := op:from-sparql('SELECT * WHERE {?person </has_dob> ?dob. }', "sparql")

return $questions  => op:join-inner(
    $people,
    op:on(
      op:view-col("lexicon","people"),
      op:view-col("sparql", "person")
    )
  ) => op:result()

然而,在op:join-inner返回的结果是,尽管在两个运具有相同的条目空:从导致$people$questions 。 一块返回的结果的下面可以看到。

返回结果

lexicon.people

{"lexicon.people":"/people/Aaren_DETERS/000000000055933"}
{"lexicon.people":"/people/Aaren_HOWK/000000000117433"}
{"lexicon.people":"/people/Aaren_HUSTEDT/000000000038649"}
{"lexicon.people":"/people/Aaren_SHUSTA/000000000123065"}
{"lexicon.people":"/people/Aaren_SIEBERS/000000000035010"}
{"lexicon.people":"/people/Aarika_BETHARD/000000000048955"}
{"lexicon.people":"/people/Aarika_CHO/000000000093078"}
{"lexicon.people":"/people/Aarika_EVORA/000000000117911"}
{"lexicon.people":"/people/Aarika_LUCKRITZ/000000000001593"}
{"lexicon.people":"/people/Aarika_MCALPHIN/000000000043365"}
{"lexicon.people":"/people/Aarika_PAET/000000000067579"}
{"lexicon.people":"/people/Aarika_SENGUN/000000000047752"}
{"lexicon.people":"/people/Aarika_WEDEMEYER/000000000022594"}
......

sparql.person

......
{"sparql.person":"/people/Aaren_CRIBLEZ/000000000087536", "sparql.dob":"1999-07-21T00:19:21"}
{"sparql.person":"/people/Aaren_DEBRITO/000000000049208", "sparql.dob":"2018-10-09T08:09:48"}
{"sparql.person":"/people/Aaren_DEMASTERS/000000000091082", "sparql.dob":"2014-08-21T06:43:44"}
{"sparql.person":"/people/Aaren_DETERS/000000000055933", "sparql.dob":"2011-09-11T02:44:22"}
{"sparql.person":"/people/Aaren_GARY/000000000100658", "sparql.dob":"1998-06-04T00:39:23"}
{"sparql.person":"/people/Aaren_HANNAWAY/000000000045087", "sparql.dob":"2002-06-17T05:45:15"}
{"sparql.person":"/people/Aaren_HOWK/000000000117433", "sparql.dob":"2002-06-21T06:00:34"}
{"sparql.person":"/people/Aaren_HUSTEDT/000000000038649", "sparql.dob":"2018-06-07T14:56:39"}
{"sparql.person":"/people/Aaren_JURICH/000000000039301", "sparql.dob":"2003-07-14T16:20:05"}
{"sparql.person":"/people/Aaren_KRACK/000000000101407", "sparql.dob":"2014-03-19T06:25:39"}
{"sparql.person":"/people/Aaren_MACCONNELL/000000000053205", "sparql.dob":"1995-06-21T16:15:53"}
.....

我也做其中使用下面的代码使用来产生结果的一部分一些额外的测试op:from-sparql

let $query = 'SELECT * WHERE {?person </has_age> ? age . 
                              FILTER(?age > 75)}'
let $questions2 := op:from-sparql($query, "sparql2")

利用这个结果我进行op:join-inner它完美地工作。 这使我觉得op:from-lexicons可能会返回一个特定的数据格式不兼容op:from-sparql ? 任何澄清或提醒将不胜感激。

== ==更新

查询用于铸造

let $questions := op:from-sparql('SELECT * WHERE {?person </has_dob> ?dob. }', "sparql")
                => op:select((  "person", op:as('person_string',fn:string(op:col('person'))) ))

==更新2 ==

import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
let $people := op:from-lexicons(
  map:entry("people",cts:uri-reference()),
  "lexicon"
)=>op:where(
     cts:path-geospatial-query("people_data/location",
    cts:circle(7500, cts:point(89.39101918779838, 51.97989163203445)),
    "type=long-lat-point")
  )

let $questions := op:from-sparql('SELECT * WHERE {?person </has_dob> ?dob. }', "sparql") 
                => op:select(( "dob", op:as('personStr',ofn:string(op:col('person'))) ))

return $questions  => op:join-inner(
    $people,
    op:on(
      "people","personStr"
    )
  ) => op:select(("personStr","dob")) => op:count("Row Count", "personStr") => op:result()

Answer 1:

我相信URI词库类型为XS:字符串和三元组主语通常类型为SEM:IRI。

检查的一种方式是使用一个运算:对SPARQL行与OXS选择():字符串()光学表达铸受试者值为字符串的内部联接之前进行。

如果这样的作品,那么它可能是有益的使用TDE模板来创建与XS科目为:字符串数据类型,而不是SEM:IRI的数据类型。

希望帮助,



文章来源: Geospatial Queries with Optics API (MarkLogic)