简体   繁体   中英

How to filter sparql query result with a pattern?

When trying to filter a sparql result in MarkLogic with the following pattern,

SELECT ...
WHERE
{
    ...
    FILTER ( EXISTS { ?parent <http://www.w3.org/2004/02/skos/core#broader>+ ?root } )
}

I get the following error:

[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected {, expecting (
Stack Trace

At line 17 column 19:
In xxxx
17. FILTER ( EXISTS { ?parent <http://www.w3.org/2004/02/skos/core#broader>+ ?root } )

Does MarkLogic not support Sparql 1.1 syntax or is my query incorrect?

I tried the following as well:

FILTER EXISTS { ?parent <http://www.w3.org/2004/02/skos/core#broader>+ ?root } 

And the error message is:

[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected {, expecting (

There is currently a request for enhancement for this specific case at MarkLogic. An updated version of MarkLogic is forthcoming that has it corrected in it. Contact your MarkLogic SE or AE, they can point you further to the timeframe and other information.

You can use a regex expression if you for specific patterns

Example if your query is something like this:

 SELECT ?subject ?term
 WHERE {
 ?subject <http://www.smartlogic.com/schemas/docinfo.rdf#tagged_with> ?term 
 FILTER regex(?term, "red", "i" )
 }

where "i" is for case insensitivity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM