In marklogic, triples can be embedded into an existing document. How can i use cts search query to return the document. An example of a document could be
<ContentVersion>
<Name>Testing</Name>
<Status>Approved</Status>
<sem:triples xmlns:sem="http://marklogic.com/semantics">
<sem:triple>
<sem:subject>http://mycontent/content/Testing</sem:subject>
<sem:predicate>is</sem:predicate>
<sem:object>Approved</sem:object>
</sem:triple>
</sem:triples>
</ContentVersion>
if try the below query
let $query := cts:word-query('Testing',"case-insensitive")
let $sparql := "PREFIX cts: <http://marklogic.com/cts#>
DESCRIBE ?s
WHERE{
?s ?p ?o .
FILTER cts:contains(?o, cts:word-query('Testing'))
}"
let $results := sem:sparql($sparql,(),("default-graph=magician"),($query))
return(sem:rdf-serialize($results,'rdfxml'))
I get an empty result. Any ideas on why nothing is returned? I am using MarkLogic 7
The cts:contains is focused to ?o, which only contains 'Approved'. That is why the sem:sparql is not returning results, not because you are using the cts query the wrong way.
(update..)
To confirm the approach is valid, I tried this and it works for me:
Run this with QC against any database that has triple index enabled.
Are you sure you insert your docs with collection 'magician'? That is how you can get embedded triples inside a specific graph with MarkLogic.
HTH!