Failed to get result.

I am trying to implement a SPARQL query that takes a substring from an object in my RDF data.

With the following query, I get an empty result in a column ?Substring. I get the actual output in the columns ?subject, ?predicateand ?object, but the column ?Substringdoes not output the result.

SELECT * WHERE
{
   ?S ?P ?O .
   BIND(SUBSTR(?O, 2, 3) AS ?Substring)
}
+4
source share
1 answer

Are the values โ€‹โ€‹in ?Oactual string literals? If not, it SUBSTR()wonโ€™t do anything, since it is defined only for working on literals. If the values โ€‹โ€‹are URI / Blank Nodes, you will always get an empty column with the query written as is.

STR() , , :

SELECT * WHERE
{
  ?S ?P ?O .
  BIND(SUBSTR(STR(?O), 2, 3) AS ?Substring)
}

SPARQL, , , , , . , , , .

, , , SPARQL SUBSTR() , 3 , 2. , Java, , 2 3, :

BIND(SUBSTR(STR(?O), 2, 1)

. 1 , 2

+3

Source: https://habr.com/ru/post/1534600/


All Articles