I'm running the same SPARQL Query on apache-jena-2.11.1 (eclipse 64jvm), Protégé and TopBraid Composer (free edition).
Jena returns an empty set while both Protégé and TopBraid Composer return/find the correct results.
The SPARQL Query:
PREFIX core: <http://www.linked-usdl.org/ns/usdl-core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX price: <http://www.linked-usdl.org/ns/usdl-price#>
PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX gr: <http://purl.org/goodrelations/v1#>
PREFIX cloudtaxonomy: <http://rdfs.genssiz.org/CloudTaxonomy#>
SELECT REDUCED ?offering
WHERE
{ { SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Location .
?f rdfs:label ?value
FILTER REGEX(?value, "tokyo", "i")
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Location .
?f rdfs:label ?value
FILTER REGEX(?value, "tokyo", "i")
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasMinValue ?value
FILTER ( ?value >= 3.7 )
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasMinValue ?value
FILTER ( ?value >= 150.0 )
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Feature .
?f rdfs:label ?value
FILTER REGEX(?value, "Virtual Machine", "i")
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Feature .
?f rdfs:label ?value
FILTER REGEX(?value, "Virtual Machine", "i")
}
}
}
}
Jena's loading the information from the model correctly and every platform has the same data. No reasoner is being used on either of them.
JAVA source.
You can download the dataset from here.
Protégé and TopBraid find 19 results, Jena finds 0.
Jena: VERSION: 2.11.1
Jena: BUILD_DATE: 2014-01-18T19:01:20+0000
ARQ: VERSION: 2.11.1
ARQ: BUILD_DATE: 2014-01-18T19:01:20+0000
RIOT: VERSION: 2.11.1
RIOT: BUILD_DATE: 2014-01-18T19:01:20+0000
$ sparql --query query.qv --data amazonOnDemand_fullset0.ttl
------------
| offering |
============
------------
Any ideas on what might be the problem here? Running eclipse with jdk 1.8.0 64bits.
When I run this using Jena's command line tools (after downloading your data and storing your query in query.rq
), I get a number of results. I don't know if they're what you expected, or what you're getting from Protégé, since you didn't post them, but it's not empty, so I assume it's what you're expecting.
$ sparql --version
Jena: VERSION: 2.11.0
Jena: BUILD_DATE: 2013-09-12T10:49:49+0100
ARQ: VERSION: 2.11.0
ARQ: BUILD_DATE: 2013-09-12T10:49:49+0100
RIOT: VERSION: 2.11.0
RIOT: BUILD_DATE: 2013-09-12T10:49:49+0100
$ sparql --query query.rq --data amazonOnDemand_fullset0.ttl
---------------------------------------------------------------------------------------------------------------------------------------
| offering |
=======================================================================================================================================
| <http://PricingAPIAmazonOnDemandOfferings.com#m3.2xlarge_2956_TIME247806256606408linux-AmazonOnDemandInstance_TIME247806256614533> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.4xlarge_3132_TIME247806265310896linux-AmazonOnDemandInstance_TIME247806265318593> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.xlarge_3352_TIME247806280140383linux-AmazonOnDemandInstance_TIME247806280147225> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.xlarge_3044_TIME247806261045248linux-AmazonOnDemandInstance_TIME247806261052518> |
| <http://PricingAPIAmazonOnDemandOfferings.com#hi1.4xlarge_3462_TIME247806285100936linux-AmazonOnDemandInstance_TIME247806285106495> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.4xlarge_3308_TIME247806277291059linux-AmazonOnDemandInstance_TIME247806277311157> |
| <http://PricingAPIAmazonOnDemandOfferings.com#cr1.8xlarge_3330_TIME247806279000311linux-AmazonOnDemandInstance_TIME247806279016134> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.4xlarge_3396_TIME247806282156677linux-AmazonOnDemandInstance_TIME247806282162664> |
| <http://PricingAPIAmazonOnDemandOfferings.com#cc2.8xlarge_3220_TIME247806271984550linux-AmazonOnDemandInstance_TIME247806271997379> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.xlarge_3264_TIME247806274243312linux-AmazonOnDemandInstance_TIME247806274255286> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.2xlarge_3286_TIME247806275687432linux-AmazonOnDemandInstance_TIME247806275695557> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.medium_3000_TIME247806258807012linux-AmazonOnDemandInstance_TIME247806258833953> |
| <http://PricingAPIAmazonOnDemandOfferings.com#hs1.8xlarge_3440_TIME247806284122937linux-AmazonOnDemandInstance_TIME247806284128497> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.large_3022_TIME247806259925275linux-AmazonOnDemandInstance_TIME247806259933827> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.2xlarge_3110_TIME247806264234541linux-AmazonOnDemandInstance_TIME247806264242239> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.8xlarge_3418_TIME247806283147932linux-AmazonOnDemandInstance_TIME247806283153491> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c1.xlarge_3198_TIME247806269972105linux-AmazonOnDemandInstance_TIME247806269986217> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.2xlarge_3374_TIME247806281161573linux-AmazonOnDemandInstance_TIME247806281167987> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.8xlarge_3154_TIME247806266383402linux-AmazonOnDemandInstance_TIME247806266391099> |
---------------------------------------------------------------------------------------------------------------------------------------
After the edit, you've provided complete code, but it still works. I've downloaded it, along with a copy of the data, and aside from a change to the path name, I get the results you'd expect.
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.util.FileManager;
public class JenaVsProtegeAndTopBraidExample {
public static void main(String[] args) {
Model data = FileManager.get().loadModel( "/home/taylorj/Downloads/amazonOnDemand_fullset0.ttl", "TTL");
test(data);
}
private static void test(Model model) {
String q = "PREFIX core: <http://www.linked-usdl.org/ns/usdl-core#> PREFIX price: <http://www.linked-usdl.org/ns/usdl-price#> PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX gr: <http://purl.org/goodrelations/v1#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX cloudtaxonomy: <http://rdfs.genssiz.org/CloudTaxonomy#> PREFIX spin: <http://spinrdf.org/spin#> SELECT REDUCED ?offering WHERE { { SELECT REDUCED ?offering WHERE { ?offering rdf:type core:ServiceOffering. ?offering core:includes ?serv . { ?serv gr:qualitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:Location . ?f rdfs:label ?value FILTER regex(?value, 'tokyo', 'i') }UNION{ ?serv core:hasServiceModel ?model . ?model gr:qualitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:Location . ?f rdfs:label ?value FILTER regex(?value, 'tokyo', 'i') } } } . { SELECT REDUCED ?offering WHERE { ?offering rdf:type core:ServiceOffering . ?offering core:includes ?serv . { ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize . ?f gr:hasValue ?value FILTER(?value >= 3.7) }UNION{ ?serv gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:MemorySize . ?f gr:hasValue ?value FILTER(?value >= 3.7) }UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize . ?f gr:hasValue ?value FILTER(?value >= 3.7) }UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:MemorySize . ?f gr:hasValue ?value FILTER(?value >= 3.7) } UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:MemorySize . ?f gr:hasMinValue ?value FILTER(?value >= 3.7) } } } . { SELECT REDUCED ?offering WHERE { ?offering rdf:type core:ServiceOffering . ?offering core:includes ?serv . { ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize . ?f gr:hasValue ?value FILTER(?value >= 150.0) }UNION{ ?serv gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:DiskSize . ?f gr:hasValue ?value FILTER(?value >= 150.0) }UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize . ?f gr:hasValue ?value FILTER(?value >= 150.0) }UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:DiskSize . ?f gr:hasValue ?value FILTER(?value >= 150.0) } UNION{ ?serv core:hasServiceModel ?model . ?model gr:quantitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:DiskSize . ?f gr:hasMinValue ?value FILTER(?value >= 150.0) } } } . { SELECT REDUCED ?offering WHERE { ?offering rdf:type core:ServiceOffering. ?offering core:includes ?serv . { ?serv gr:qualitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:Feature . ?f rdfs:label ?value FILTER regex(?value, 'Virtual Machine', 'i') }UNION{ ?serv core:hasServiceModel ?model . ?model gr:qualitativeProductOrServiceProperty ?f . ?f rdf:type cloudtaxonomy:Feature . ?f rdfs:label ?value FILTER regex(?value, 'Virtual Machine', 'i') } } } }";
Query query = QueryFactory.create(q);
System.out.println(query.toString());
QueryExecution exec = QueryExecutionFactory.create(query, model);
ResultSet results = exec.execSelect();
ResultSetFormatter.out(System.out, results, query);
exec.close();
}
}
Output:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#>
PREFIX price: <http://www.linked-usdl.org/ns/usdl-price#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX core: <http://www.linked-usdl.org/ns/usdl-core#>
PREFIX cloudtaxonomy: <http://rdfs.genssiz.org/CloudTaxonomy#>
PREFIX gr: <http://purl.org/goodrelations/v1#>
SELECT REDUCED ?offering
WHERE
{ { SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Location .
?f rdfs:label ?value
FILTER regex(?value, "tokyo", "i")
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Location .
?f rdfs:label ?value
FILTER regex(?value, "tokyo", "i")
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasValue ?value
FILTER ( ?value >= 3.7 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:MemorySize .
?f gr:hasMinValue ?value
FILTER ( ?value >= 3.7 )
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasValue ?value
FILTER ( ?value >= 150.0 )
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:quantitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:DiskSize .
?f gr:hasMinValue ?value
FILTER ( ?value >= 150.0 )
}
}
}
{ SELECT REDUCED ?offering
WHERE
{ ?offering rdf:type core:ServiceOffering .
?offering core:includes ?serv
{ ?serv gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Feature .
?f rdfs:label ?value
FILTER regex(?value, "Virtual Machine", "i")
}
UNION
{ ?serv core:hasServiceModel ?model .
?model gr:qualitativeProductOrServiceProperty ?f .
?f rdf:type cloudtaxonomy:Feature .
?f rdfs:label ?value
FILTER regex(?value, "Virtual Machine", "i")
}
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------
| offering |
=======================================================================================================================================
| <http://PricingAPIAmazonOnDemandOfferings.com#m3.2xlarge_2956_TIME247806256606408linux-AmazonOnDemandInstance_TIME247806256614533> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.4xlarge_3132_TIME247806265310896linux-AmazonOnDemandInstance_TIME247806265318593> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.xlarge_3352_TIME247806280140383linux-AmazonOnDemandInstance_TIME247806280147225> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.xlarge_3044_TIME247806261045248linux-AmazonOnDemandInstance_TIME247806261052518> |
| <http://PricingAPIAmazonOnDemandOfferings.com#hi1.4xlarge_3462_TIME247806285100936linux-AmazonOnDemandInstance_TIME247806285106495> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.4xlarge_3308_TIME247806277291059linux-AmazonOnDemandInstance_TIME247806277311157> |
| <http://PricingAPIAmazonOnDemandOfferings.com#cr1.8xlarge_3330_TIME247806279000311linux-AmazonOnDemandInstance_TIME247806279016134> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.4xlarge_3396_TIME247806282156677linux-AmazonOnDemandInstance_TIME247806282162664> |
| <http://PricingAPIAmazonOnDemandOfferings.com#cc2.8xlarge_3220_TIME247806271984550linux-AmazonOnDemandInstance_TIME247806271997379> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.xlarge_3264_TIME247806274243312linux-AmazonOnDemandInstance_TIME247806274255286> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m2.2xlarge_3286_TIME247806275687432linux-AmazonOnDemandInstance_TIME247806275695557> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.medium_3000_TIME247806258807012linux-AmazonOnDemandInstance_TIME247806258833953> |
| <http://PricingAPIAmazonOnDemandOfferings.com#hs1.8xlarge_3440_TIME247806284122937linux-AmazonOnDemandInstance_TIME247806284128497> |
| <http://PricingAPIAmazonOnDemandOfferings.com#m1.large_3022_TIME247806259925275linux-AmazonOnDemandInstance_TIME247806259933827> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.2xlarge_3110_TIME247806264234541linux-AmazonOnDemandInstance_TIME247806264242239> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.8xlarge_3418_TIME247806283147932linux-AmazonOnDemandInstance_TIME247806283153491> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c1.xlarge_3198_TIME247806269972105linux-AmazonOnDemandInstance_TIME247806269986217> |
| <http://PricingAPIAmazonOnDemandOfferings.com#i2.2xlarge_3374_TIME247806281161573linux-AmazonOnDemandInstance_TIME247806281167987> |
| <http://PricingAPIAmazonOnDemandOfferings.com#c3.8xlarge_3154_TIME247806266383402linux-AmazonOnDemandInstance_TIME247806266391099> |
---------------------------------------------------------------------------------------------------------------------------------------