Hello Burak

If you want to get tens of result columns, not a long narrow result set
for all,
then you can simply remove extra nesting from your original query.
You can put all UNION mambers to one level. Even if UNION is specified
in the SPARQL spec as a binary operation you don't have to write so many
braces (like '+' that is binary as well, but you don't have to write
((((1+2)+3)+4)+5), because 1+2+3+4+5 is quite OK).

So

SELECT  *
WHERE
{
  { ?y_0 <http://www.w3.org/2002/07/owl#sameAs>
<http://dbpedia.org/resource/Tetrahydrocannabinol> .
    ?Int_0
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
?y_0 .
    ?Int_0
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
?IntDrug_0 .
    ?Int_0
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> ?IntEffect_0
  }
  UNION
  { ?y_1 <http://www.w3.org/2002/07/owl#sameAs>
<http://dbpedia.org/resource/Mescaline> .
    ?Int_1
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
?y_1 .
    ?Int_1
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
?IntDrug_1 .
    ?Int_1
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> ?IntEffect_1
  }

  UNION
  { ?y_2 <http://www.w3.org/2002/07/owl#sameAs>
<http://dbpedia.org/resource/Bacillus_Calmette-Gu%C3%A9rin> .
    ?Int_2
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
?y_2 .
    ?Int_2
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
?IntDrug_2 .
    ?Int_2
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> ?IntEffect_2
  }

...

  UNION
  { ?y_30 <http://www.w3.org/2002/07/owl#sameAs>
<http://dbpedia.org/resource/Cannabinol> .
    ?Int_30
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
?y_30 .
    ?Int_30
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
?IntDrug_30 .
    ?Int_30
<http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> ?IntEffect_30
  }
}


will work fine.

Best Regards

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com



On Mon, 2012-12-17 at 20:05 +0100, Patrick van Kleef wrote:
> Hello Burak Yönyül,
> 
> 
> > I cannot execute queries which are greater than a few kilobytes on 
> > Virtuoso. I've loaded example drugbank dataset into Virtuoso Opensource 6.1 
> > and I'm trying to execute the query in the file I've attached here, on my 
> > local drugbank dataset with the sparql endpoint 
> > "http://155.223.24.47:8893/drugbank/sparql";. But when I execute this I get 
> > "HTTPException: 400 Bad Request". How can I execute queries greater than 25 
> > KB?
> 
> I promised i would also have a look at the query itself and see if it could 
> be simplified.
> 
> Your query consists of a union of repeating patterns like this:
> 
> { ?y_0 <http://www.w3.org/2002/07/owl#sameAs> 
> <http://dbpedia.org/resource/Tetrahydrocannabinol> .
> ?Int_0 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
> ?y_0 .
> ?Int_0 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
> ?IntDrug_0 .
> ?Int_0 <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> 
> ?IntEffect_0
> }
> UNION
> { ?y_1 <http://www.w3.org/2002/07/owl#sameAs> 
> <http://dbpedia.org/resource/Mescaline> .
> ?Int_1 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
> ?y_1 .
> ?Int_1 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
> ?IntDrug_1 .
> ?Int_1 <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> 
> ?IntEffect_1
> }
> etc.
> 
> In this case you should be able to use the SPARQL 1.1 IN construction[1] as 
> in:
> 
> SELECT * WHERE {
>   ?y_0 <http://www.w3.org/2002/07/owl#sameAs> ?d_1 .
>   FILTER (?d_1 in (
>       <http://dbpedia.org/resource/Tetrahydrocannabinol> , 
>       <http://dbpedia.org/resource/Mescaline>,
>       <http://dbpedia.org/resource/Bacillus_Calmette-Gu%C3%A9rin>,
>       <http://dbpedia.org/resource/Sugammadex>,
>       <http://dbpedia.org/resource/Carnitine>
>   )).
> 
>   ?Int_0 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug1> 
> ?y_0 .
>   ?Int_0 
> <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/interactionDrug2> 
> ?IntDrug_0 .
>   ?Int_0 <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/text> 
> ?IntEffect_0
> }
> 
> which results in a much shorter query.
> 
> See also:
> [1] http://www.w3.org/TR/sparql11-query/#func-in
> 
> 
> Best regards,
> 
> Patrick

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Virtuoso-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to