Project Polygene has retired. For details please refer to its Attic page.
OpenRDF Index/Query
Polygene™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

OpenRDF Index/Query

code

docs

tests

Index/Query services backed by OpenRDF Sesame framework for processing RDF data.

Table 66. Artifact

Group IDArtifact IDVersion

org.apache.polygene.extensions

org.apache.polygene.extension.indexing-rdf

3.0.0


In Memory

Assembly is done using the provided Assembler:

new RdfMemoryStoreAssembler().assemble( module );

No configuration needed.

On Filesystem

Assembly

Assembly is done using the provided Assembler:

new RdfNativeSesameStoreAssembler().assemble( module );
Configuration

Here are the configuration properties for the Native RDF Index/Query:

public interface NativeConfiguration extends ConfigurationComposite
{
    @Optional @Matches( "([spoc][spoc][spoc][spoc],?)*" ) Property<String> tripleIndexes();

    @Optional Property<String> dataDirectory();

    @UseDefaults Property<Boolean> forceSync();
}

In a RDBMS

Assembly

Assembly is done using the provided Assembler:

new RdfRdbmsSesameStoreAssembler().assemble( module );
Configuration

Here are the configuration properties for the RDBMS based RDF Index/Query:

public interface RdbmsRepositoryConfiguration
{
    Property<String> jdbcDriver();
    Property<String> jdbcUrl();
    Property<String> user();
    Property<String> password();
}

Named RDF Queries

RDF queries are rather difficult to create manually. Not only do you need to learn a difficult language and a new syntax, but also need to understand the indexing model that happens in Apache Polygene RDF indexing system.

Below follows a large set of working queries, which can be used as a starting point. See the testcases for details of the Entity model that is being indexed.

"PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "\n" + "}", // script01
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Domain>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "FILTER (?v0 = \"Gaming\")\n" + "}", // script02
"PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "\n" + "}", // script03
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:placeOfBirth ?v0. \n" + "?v0 ns2:name ?v1. \n" + "FILTER (?v1 = \"Kuala Lumpur\")\n" + "}", // script04
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:mother ?v0. \n"
    + "?v0 ns1:placeOfBirth ?v1. \n" + "?v1 ns2:name ?v2. \n" + "FILTER (?v2 = \"Kuala Lumpur\")\n" + "}", // script05
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER (?v0 >= \"1973\")\n" + "}", // script06
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "?entity ns1:placeOfBirth ?v1. \n" + "?v1 ns2:name ?v2. \n"
    + "FILTER ((?v0 >= \"1900\") && (?v2 = \"Penang\"))\n" + "}", // script07
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER ((?v0 = \"1970\") || (?v0 = \"1975\"))\n" + "}", // script08
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Female>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER ((?v0 = \"1970\") || (?v0 = \"1975\"))\n" + "}", // script09
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER (!(?v0 = \"1975\"))\n" + "}", // script10
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "OPTIONAL {?entity ns1:email ?v0}. \n" + "FILTER (bound(?v0))\n" + "}", // script11
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "OPTIONAL {?entity ns1:email ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script12
"PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (bound(?v0))\n" + "}", // script13
"PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Male>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script14
"PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script15
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "\n" + "}", // script16
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "\n" + "} ", // script17
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "\n" + "}\n", // script18
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "FILTER (?v0 > \"D\")\n" + "} ", // script19
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:yearOfBirth ?v0. \n" + "?entity ns2:name ?v1. \n" + "FILTER (?v0 > \"1973\")\n" + "}\n"
    , // script20
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n"
    + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n"
    + "?entity ns1:placeOfBirth ?v0. \n" + "?v0 ns2:name ?v1. \n" + "?entity ns1:yearOfBirth ?v2. \n" + "\n"
    + "}", // script21
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "FILTER regex(?v0,\"J.*Doe\")\n" + "}", // script22
"PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n"
    + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n"
    + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n"
    + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Domain>. \n"
    + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n"
    + "FILTER (?v0 = ?domain)\n" + "}" // script24