Discussion:
[Dbpedia-discussion] SPARQL endpoint line of code limit
Stefano Ortona
2012-06-18 16:15:04 UTC
Permalink
Hello,

I'm using the SPARQL endpoint and get error:

"Virtuoso 37000 Error SP031: SPARQL: Internal error: The length of generated SQL text has exceeded 10000 lines of code".

Is there a way to avoid this or i have to reduce line of code of my query?
Thanks,

Stefano
Ivan Mikhailov
2012-06-20 17:56:56 UTC
Permalink
Hello Stefano,

What's the text of the query? Is is about "The" dbpedia endpoint or some
clone of it with additional data and RDF Views?

10000 lines of code is ~200K of text. The SPARQL compiler stops because
the SQL compiler, the successor in the processing pipeline, will fail to
compile it in any reasonable time.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Post by Stefano Ortona
"Virtuoso 37000 Error SP031: SPARQL: Internal error: The length of generated SQL text has exceeded 10000 lines of code".
Is there a way to avoid this or i have to reduce line of code of my query?
Thanks,
Stefano
Stefano Ortona
2012-06-21 17:39:41 UTC
Permalink
Hi Ivan,

my query is very simple:

"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"

Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint, http://dbpedia.org/sparql.

Regards,
Stefano
Post by Ivan Mikhailov
Hello Stefano,
What's the text of the query? Is is about "The" dbpedia endpoint or some
clone of it with additional data and RDF Views?
10000 lines of code is ~200K of text. The SPARQL compiler stops because
the SQL compiler, the successor in the processing pipeline, will fail to
compile it in any reasonable time.
Best Regards,
Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Post by Stefano Ortona
"Virtuoso 37000 Error SP031: SPARQL: Internal error: The length of generated SQL text has exceeded 10000 lines of code".
Is there a way to avoid this or i have to reduce line of code of my query?
Thanks,
Stefano
Hello Stefano,
What's the text of the query? Is is about "The" dbpedia endpoint or some
clone of it with additional data and RDF Views?
10000 lines of code is ~200K of text. The SPARQL compiler stops because
the SQL compiler, the successor in the processing pipeline, will fail to
compile it in any reasonable time.
Best Regards,
Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Post by Stefano Ortona
"Virtuoso 37000 Error SP031: SPARQL: Internal error: The length of generated SQL text has exceeded 10000 lines of code".
Is there a way to avoid this or i have to reduce line of code of my query?
Thanks,
Stefano
Kingsley Idehen
2012-06-21 17:45:29 UTC
Permalink
Post by Stefano Ortona
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint,http://dbpedia.org/sparql.
Send a SPARQL URL.
--
Regards,

Kingsley Idehen
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog: http://www.openlinksw.com/blog/~kidehen
Twitter/Identi.ca handle: @kidehen
Google+ Profile: https://plus.google.com/112399767740508618350/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
Stefano Ortona
2012-06-21 17:53:03 UTC
Permalink
Sorry i don't get you, what do you mean?

Stefano
Post by Kingsley Idehen
Post by Stefano Ortona
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint,http://dbpedia.org/sparql.
Send a SPARQL URL.
--
Regards,
Kingsley Idehen
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog: http://www.openlinksw.com/blog/~kidehen
Google+ Profile: https://plus.google.com/112399767740508618350/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
Dbpedia-discussion mailing list
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
Kingsley Idehen
2012-06-21 18:18:13 UTC
Permalink
Post by Stefano Ortona
Sorry i don't get you, what do you mean?
Goto: http://dbpedia.org/sparql

Type in your query. Execute, and then send URL (as presented in browser
address bar) as a reply to this message.


Kingsley
Post by Stefano Ortona
Stefano
Post by Kingsley Idehen
Post by Stefano Ortona
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint,http://dbpedia.org/sparql.
Send a SPARQL URL.
--
Regards,
Kingsley Idehen
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog: http://www.openlinksw.com/blog/~kidehen
Google+ Profile: https://plus.google.com/112399767740508618350/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
Dbpedia-discussion mailing list
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
--
Regards,

Kingsley Idehen
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog: http://www.openlinksw.com/blog/~kidehen
Twitter/Identi.ca handle: @kidehen
Google+ Profile: https://plus.google.com/112399767740508618350/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
Ivan Mikhailov
2012-06-21 18:24:03 UTC
Permalink
Stefano,
Post by Stefano Ortona
Post by Kingsley Idehen
Send a SPARQL URL.
Sorry i don't get you, what do you mean?
Kingsley meas the simplest way to provide a sample. Just post the URL
that is in your browser's address bar when you're at the results page
and you don't see what you've expected (e.g., an error). The URL will be
of form http://dbpedia.org/sparql?query=... and pretty lengthy.
One can immediately reproduce the issue by clicking that URL. It is also
possible to access the query page with exactly your text of query and
all configuration parameters by replacing "?query=" word in URL with
"?qtxt=" and trying again.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Ivan Mikhailov
2012-06-21 18:17:27 UTC
Permalink
Hello Stefano,
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint, http://dbpedia.org/sparql.
7 lines of SQL text per triple pattern if default graph is not
specified, 9 lines if it is specified. So it's some about 700 or 900
lines, not 10000 . Terrible but not fatal.

I'd query
SELECT DISTINCT ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }

A single triple pattern with IN operator would be much cheaper.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Stefano Ortona
2012-06-22 16:41:12 UTC
Permalink
Hello Ivan,

I can't use the query you suggested me because i need to keep the mapping between resource and type of the resource (basically i have a list of dbpedia resources and for each of them i want to retrieve all the rdf:types, doing that using only one query).

I thing i'll solve the problem installing dbpedia datasets locally, so i have a question: can you tell me what find i've to download to retrieve all the informations about type? (I want the query "select ?x where <resource> rdf:type ?x" made locally returned me exactly the same results the one of dpedia endpoint)?

I've already downloaded the Ontology Infobox Types from core datasets, is it enough?

Cheers,
Stefano
Post by Ivan Mikhailov
Hello Stefano,
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Basically i wanna retrieve the rdf:types for 100 different dbpedia resources, is that ~200K of text? (seems strange)
I'm using the DBPedia SPARQL endpoint, http://dbpedia.org/sparql.
7 lines of SQL text per triple pattern if default graph is not
specified, 9 lines if it is specified. So it's some about 700 or 900
lines, not 10000 . Terrible but not fatal.
I'd query
SELECT DISTINCT ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }
A single triple pattern with IN operator would be much cheaper.
Best Regards,
Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Ivan Mikhailov
2012-06-22 17:02:34 UTC
Permalink
Hello Stefano.
Post by Ivan Mikhailov
Post by Ivan Mikhailov
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
I'd query
Post by Ivan Mikhailov
SELECT DISTINCT ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }
I can't use the query you suggested me because i need to keep the mapping between resource and type of the resource (basically i have a list of dbpedia resources and for each of them i want to retrieve all the rdf:types, doing that using only one query).
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>, <resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't preserve the mapping if you return only dependent part of the mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more than one type or if at least one resource has no type at all.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Matthew Haynes
2012-06-23 15:45:48 UTC
Permalink
Yep, all seems good now.

Thanks!

Matt
Post by Ivan Mikhailov
Hello Stefano.
Post by Ivan Mikhailov
Post by Ivan Mikhailov
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
I'd query
Post by Ivan Mikhailov
SELECT DISTINCT ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }
I can't use the query you suggested me because i need to keep the
mapping between resource and type of the resource (basically i have a list
of dbpedia resources and for each of them i want to retrieve all the
rdf:types, doing that using only one query).
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>, <resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't preserve
the mapping if you return only dependent part of the mapping but not the
key.
Anyway the original query is wrong, esp. if many resources have more than
one type or if at least one resource has no type at all.
Best Regards,
Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Dbpedia-discussion mailing list
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
Stefano Ortona
2012-06-25 15:08:41 UTC
Permalink
Hello Ivan,
Post by Ivan Mikhailov
Hello Stefano.
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>, <resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't preserve the mapping if you return only dependent part of the mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more than one type or if at least one resource has no type at all.
Maybe I didn't explain myself properly, let's go through an example. Suppose I have 3 resource uri, <http://dbpedia.org/resource/Spain>, <http://dbpedia.org/resource/Cambridge>, <http://dbpedia.org/resource/Batman>. I want to retrieve the rdf:type for every uri. I don't want just a list of union of all types, i wanna find every type for every single entity, so i want to able to say: types of Spain are t11,t12,t13...t1n, types of Cambdrige are t21,t22,t23..t2n, types of Batman are t31,t32,t33...t3n.

Using the query you suggested, the final result will contain in variable ?t the union of all types, therefore i'm not able to distinguish types of Spain, Cambridge and Batman.
The solution is to use a different variable for every resource, so i'm using the following query:

select distinct ?x ?y ?z
WHERE
{
{<http://dbpedia.org/resource/Spain> rdf:type ?x.}
UNION
{<http://dbpedia.org/resource/Cambridge> rdf:type ?y.}
UNION
{<http://dbpedia.org/resource/Batman> rdf:type ?z.}
}

With this query, x contains all types of Spain, y will contains all types of Cambridge and z all types of Batman. It works also if a resource has a multiple types, (variable will contain multiple values) and if a resource doesn't have any type (variable will be empty).
Problem is, using that query with 97 different resources I got the line of code limit error, any suggestion about?

Stefano
Jona Christopher Sahnwaldt
2012-06-25 15:39:29 UTC
Permalink
Hi Stefano,

when I run the the query SELECT ?s ?t ... on http://dbpedia.org/sparql
[1], it returns a nice list of (subject, type) pairs, with lots of
pairs for each subject. All you need to do is collect all the types
for each subject.

Cheers,
Christopher

[1] http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT+%3Fs+%3Ft%0D%0AWHERE%0D%0A%7B+%3Fs+a+%3Ft+.+FILTER+%28+%3Fs+IN+%28%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FBerlin%3E%2C+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FGermany%3E%29%29+%7D&format=text%2Fhtml&timeout=0&debug=on
Post by Stefano Ortona
Hello Ivan,
Hello Stefano.
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>, <resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't preserve the
mapping if you return only dependent part of the mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more than
one type or if at least one resource has no type at all.
Maybe I didn't explain myself properly, let's go through an example. Suppose
I have 3 resource uri, <http://dbpedia.org/resource/Spain>,
<http://dbpedia.org/resource/Cambridge>,
<http://dbpedia.org/resource/Batman>. I want to retrieve the rdf:type for
every uri. I don't want just a list of union of all types, i wanna find
every type for every single entity, so i want to able to say: types of Spain
are t11,t12,t13...t1n, types of Cambdrige are t21,t22,t23..t2n, types of
Batman are t31,t32,t33...t3n.
Using the query you suggested, the final result will contain in variable ?t
the union of all types, therefore i'm not able to distinguish types of
Spain, Cambridge and Batman.
The solution is to use a different variable for every resource, so i'm using
select distinct ?x ?y ?z
WHERE
{
{<http://dbpedia.org/resource/Spain> rdf:type ?x.}
UNION
{<http://dbpedia.org/resource/Cambridge> rdf:type ?y.}
UNION
{<http://dbpedia.org/resource/Batman> rdf:type ?z.}
}
With this query, x contains all types of Spain, y will contains all types of
Cambridge and z all types of Batman. It works also if a resource has a
multiple types, (variable will contain multiple values) and if a resource
doesn't have any type (variable will be empty).
Problem is, using that query with 97 different resources I got the line of
code limit error, any suggestion about?
Stefano
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Dbpedia-discussion mailing list
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
Jona Christopher Sahnwaldt
2012-06-25 15:40:59 UTC
Permalink
To be precise: I meant the query suggested by Ivan:

SELECT ?s ?t
WHERE
{ ?s a ?t . FILTER ( ?s IN (<http://dbpedia.org/resource/Berlin>,
<http://dbpedia.org/resource/Germany>)) }

Also see http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&qtxt=SELECT+%3Fs+%3Ft%0D%0AWHERE%0D%0A%7B+%3Fs+a+%3Ft+.+FILTER+%28+%3Fs+IN+%28%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FBerlin%3E%2C+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FGermany%3E%29%29+%7D&format=text%2Fhtml&timeout=0&debug=on


On Mon, Jun 25, 2012 at 5:39 PM, Jona Christopher Sahnwaldt
Post by Jona Christopher Sahnwaldt
Hi Stefano,
when I run the the query SELECT ?s ?t ... on http://dbpedia.org/sparql
[1], it returns a nice list of (subject, type) pairs, with lots of
pairs for each subject. All you need to do is collect all the types
for each subject.
Cheers,
Christopher
[1] http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT+%3Fs+%3Ft%0D%0AWHERE%0D%0A%7B+%3Fs+a+%3Ft+.+FILTER+%28+%3Fs+IN+%28%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FBerlin%3E%2C+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FGermany%3E%29%29+%7D&format=text%2Fhtml&timeout=0&debug=on
Post by Stefano Ortona
Hello Ivan,
Hello Stefano.
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>, <resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't preserve the
mapping if you return only dependent part of the mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more than
one type or if at least one resource has no type at all.
Maybe I didn't explain myself properly, let's go through an example. Suppose
I have 3 resource uri, <http://dbpedia.org/resource/Spain>,
<http://dbpedia.org/resource/Cambridge>,
<http://dbpedia.org/resource/Batman>. I want to retrieve the rdf:type for
every uri. I don't want just a list of union of all types, i wanna find
every type for every single entity, so i want to able to say: types of Spain
are t11,t12,t13...t1n, types of Cambdrige are t21,t22,t23..t2n, types of
Batman are t31,t32,t33...t3n.
Using the query you suggested, the final result will contain in variable ?t
the union of all types, therefore i'm not able to distinguish types of
Spain, Cambridge and Batman.
The solution is to use a different variable for every resource, so i'm using
select distinct ?x ?y ?z
WHERE
{
{<http://dbpedia.org/resource/Spain> rdf:type ?x.}
UNION
{<http://dbpedia.org/resource/Cambridge> rdf:type ?y.}
UNION
{<http://dbpedia.org/resource/Batman> rdf:type ?z.}
}
With this query, x contains all types of Spain, y will contains all types of
Cambridge and z all types of Batman. It works also if a resource has a
multiple types, (variable will contain multiple values) and if a resource
doesn't have any type (variable will be empty).
Problem is, using that query with 97 different resources I got the line of
code limit error, any suggestion about?
Stefano
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Dbpedia-discussion mailing list
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
Ivan Mikhailov
2012-06-25 16:53:06 UTC
Permalink
Stefano,

I'm pretty happy that the compiler survived till _union_ of 97 triple
patterns. The original explanation did not mean union, I thought it's a
peculiar join.
The length of union as big as 97 is far beyond any practical purpose.
Clearly no need to increase the limit. Just select two columns and fill
in your data structure at client side.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com
Post by Stefano Ortona
Hello Ivan,
Post by Ivan Mikhailov
Hello Stefano.
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't
preserve the mapping if you return only dependent part of the
mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more
than one type or if at least one resource has no type at all.
Maybe I didn't explain myself properly, let's go through an example.
Suppose I have 3 resource uri, <http://dbpedia.org/resource/Spain>,
<http://dbpedia.org/resource/Cambridge>,
<http://dbpedia.org/resource/Batman>. I want to retrieve the rdf:type
for every uri. I don't want just a list of union of all types, i wanna
types of Spain are t11,t12,t13...t1n, types of Cambdrige are
t21,t22,t23..t2n, types of Batman are t31,t32,t33...t3n.
Using the query you suggested, the final result will contain in
variable ?t the union of all types, therefore i'm not able to
distinguish types of Spain, Cambridge and Batman.
The solution is to use a different variable for every resource, so i'm
select distinct ?x ?y ?z
WHERE
{
{<http://dbpedia.org/resource/Spain> rdf:type ?x.}
UNION
{<http://dbpedia.org/resource/Cambridge> rdf:type ?y.}
UNION
{<http://dbpedia.org/resource/Batman> rdf:type ?z.}
}
With this query, x contains all types of Spain, y will contains all
types of Cambridge and z all types of Batman. It works also if a
resource has a multiple types, (variable will contain multiple values)
and if a resource doesn't have any type (variable will be empty).
Problem is, using that query with 97 different resources I got the
line of code limit error, any suggestion about?
Stefano
Stefano Ortona
2012-07-09 12:43:04 UTC
Permalink
Post by Stefano Ortona
Hello Ivan,
Post by Ivan Mikhailov
Hello Stefano.
Post by Stefano Ortona
"
select distinct ?0 ?1 ...?x ...?100
WHERE
{
{ <certain-dbpedia-resource> rdf:type ?x.}
}
"
Query
SELECT ?s ?t
from some graph if it is known
WHERE
{ ?s a ?t . FILTER ( ?s IN (<resource1>, <resource2>,
<resource3> ...)) }
(maybe with ORDER BY by ?s for client's convenience). You can't
preserve the mapping if you return only dependent part of the
mapping but not the key.
Anyway the original query is wrong, esp. if many resources have more
than one type or if at least one resource has no type at all.
Hello Ivan,

sorry at the end you were right and the query you suggested me worked properly (and without ending with code limit), sorry I'm a bit new in sparql query!

Now i'd like to ask a question: i'm doing this query to retrieve the dbpedia type (from the ontology) of several resources. With this query i can do that, but i can retrieve all the types for a given resources, instead i'd like to have only the deepest type in the ontology (so the one which is not supertype of the others). For instance, if a query to retrieve the types of <http://dbpedia.org/resource/Spain> the above query returns me Country, PopulatedPlace and Place, instead i'd like to have only Country. Is there a way to do that in the same query? Maybe adding another FILTER option?

Thank you very much,

Stefano

Loading...