I'm trying to use MarkLogic functions in SPARQL queries.   According to
https://docs.marklogic.com/guide/semantics/semantic-searches

"In addition to SPARQL functions, you can use XQuery or JavaScript built-in
functions (for example, functions with the prefix fn, cts, math, or xdmp)
in a SPARQL query where you can use a function, which includes FILTER, BIND,
and the expressions in a SELECT statement."

It appears to work in the query console, but only intermittently.  Here's a
small repeatable test case.

For example, this, based on the example, works

PREFIX cts: <http://marklogic.com/cts#>
SELECT ?o
WHERE
{
  ?s ?p ?o
  FILTER (cts:contains(?o, cts:word-query(("sf"))))
}

But this, also based on the example, does not

SELECT ?o
WHERE
{
  ?s ?p ?o
   FILTER (<http://www.w3.org/2005/xpath-functions#starts-with/>( ?o, "sf"
) )
}

Replace "sf" with a string of your choosing.

It returns a stack trace with "[1.0-ml] XDMP-UNDFUN: (err:XPST0017)
Undefined function ()"

Stack Trace

At line 5 column 11:
In sem:sparql("SELECT ?o&#10;WHERE&#10;{&#10; ?s ?p ?o &#10; FILTER
(<http...", (), (), (), ())
3. {
4. ?s ?p ?o
5. FILTER (<http://www.w3.org/2005/xpath-functions#starts-with/>( ?o, "sf"
))
6. }
7.
At line 4 column 15:
In xdmp:eval("import module namespace amped-qconsole = &quot;
http://marklogic....";, (fn:QName("","query"), "SELECT
?o&#10;WHERE&#10;{&#10; ?s ?p ?o &#10; FILTER (<http..."), <options
xmlns="xdmp:eval"><database>11594626987012022161</database>...</options>)
2. WHERE
3. {
4. ?s ?p ?o
5. FILTER (<http://www.w3.org/2005/xpath-functions#starts-with/>( ?o, "sf"
))
6. }

In the first grouping, the < before http is highlighted on line 5 and in
the second line 4 is highlighted.

I also tried using the fn: namespace:

PREFIX fn: <http://marklogic.com/fn#>
SELECT ?o
WHERE
{
  ?s ?p ?o
   FILTER (fn:starts-with( ?o, "sf" ))
}

And that returns "[1.0-ml] XDMP-UNDFUN: (err:XPST0017) Undefined function
starts-with()"   I've also tired fn:contains with the same result.

This is on Marklogic 8.0-6.4, using developer license, but I also
reproduced it on 9.0-1.1 with an enterprise license.

And yes, before anyone tells me to do this a different way, I know I can do
this in different ways in SPARQL.  I just created a small repeatable query
that illustrates the issue I'm having.

I'm sure I'm doing something wrong, but I'm not sure what.  Can you tell me
what I'm doing wrong?

Thanks,

      Steve
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to