semantics - Searching semantically tagged documents in MarkLogic -
can 1 please point me simple examples of semantic tagging , querying semantically tagged documents in marklogic
?
i new in area,so beginner level examples do.
when "semantically tagged" mean regular xml documents happen have triples in them? discussion , examples @ http://docs.marklogic.com/guide/semantics/embedded pretty that.
start enabling triple index in database. insert test doc. xml, sem:triple
element represents semantic fact.
xdmp:document-insert( 'test.xml', <test> <source>ap newswire</source> <sem:triple date="1972-02-21" confidence="100"> <sem:subject>http://example.org/news/nixon</sem:subject> <sem:predicate>http://example.org/wentto</sem:predicate> <sem:object>china</sem:object> </sem:triple> </test>)
then query it. example query pretty complicated. understand what's going on i'd insert variations on sample document, using different uris instead of test.xml
, , see how various query terms match up. try using sparql component, without cts
query. try cts:search
no sparql, cts:query
.
xquery version "1.0-ml"; import module namespace sem = "http://marklogic.com/semantics" @ "/marklogic/semantics.xqy"; sem:sparql(' select ?country { <http://example.org/news/nixon> <http://example.org/wentto> ?country } ', (), (), cts:and-query(( cts:path-range-query( "//sem:triple/@confidence", ">", 80) , cts:path-range-query( "//sem:triple/@date", "<", xs:date("1974-01-01")), cts:or-query(( cts:element-value-query( xs:qname("source"), "ap newswire"), cts:element-value-query( xs:qname("source"), "bbc"))))))
Comments
Post a Comment