Creating FacetOntology Services for S2S

Printer-friendly version

If you have RDF data, you may want to consider using FacetOntology to provide a faceted browser through S2S. While it would be possible to create an OpenSearch service using SPARQL, FacetOntology allows you to create a single RDF configuration for your browser that covers both the S2S metadata, and the way the data should be queried. The result is that your S2S configuration should be easier to manage (with OpenSearch, you have to cross-check identifiers in the RDF configuration and the opensearch.xml file as the service evolves).

Facet Ontology Example

FacetOntology Example
This figure shows all the different components that go into an application of the FacetOntology. It starts with a domain ontology, such as a product ontology, given in yellow. The next piece is the actual instance data, which uses terms from the domain ontology to describe the data. This is represented by the nodes in orange. The terms from the FacetOntology are highlighted in green. Terms from the FacetOntology are used to create instances highlighted in blue, which inform S2S of the classes and predicates from the domain ontology to use in faceting operations. All these pieces together capture enough as much of the data model as needed to perform faceting operations over the manufacturer or price of a product dataset.

Here is what the RDF might look like (in turtle syntax) for the image above:

  #Domain ontology and instance data
  :Manufacturer a owl:Class .
  :Product a owl:Class . 
  :SeaGate a :Manufacturer ;
      rdfs:label "Seagate Technology"^^xsd:string .

  :TeraByteHardDrive a :Product ;
      :hasManufacturer :SeaGate ;
      :hasPrice "80.00"^^xsd:double

  #FacetOntology configuration
  :ProductFacetCollection a facet:FacetCollection ;
      facet:faceturi :ProductFacet ;
      facet:faceturi :ManufacturerFacet ;
      facet:faceturi :PriceFacet .
  :ProductFacet a facet:FirstOrderFacet ;
      facet:class :Product .
  :ManufacturerFacet a facet:ConnectedFacet ;
      facet:type facet:TypeObject ;
      facet:class :Manufacturer ; 
      facet:labelpredicate rdfs:label ;
      facet:nextpredicate :MftrPredicate .

  :MftrPredicate a facet:Predicate ;
      facet:predicate :hasManufacturer .

  :PriceFacet a facet:ConnectedFacet ;
      facet:type facet:TypeLiteral ;
      facet:nextpredicate :PricePredicate .
  :PricePredicate a facet:Predicate ;
      facet:predicate :hasPrice .

Note, prefixes are omitted, but can be found in the table below.

Notice that the FacetOntology configuration points at the domain ontology (i.e., classes and properties) and not the instance data itself. In a sense, the FacetOntology configuration provides a recipe for how to query for facet options and facet results.

Annotating your ontology with FacetOntology terms will allow S2S to dynamically construct SPARQL queries to implement faceting operations. In addition to the terms seen in the example above, we have created some extensions to FacetOntology to implement additional use cases, and to improve SPARQL query performance.

In addition to the FacetOntology RDF, you'll also have to include some S2S metadata to relate an s2s:SearchService to the facet:FacetCollection. Here is an example of how we would set up the S2S metadata for FacetOntology:

  :FacetOntologyService a core:FacetOntologyService ;
    rdfs:comment "A service for computer parts based on FacetOntology."^^xsd:string ;
    rdfs:label "Computer Hardware Facet Ontology Service"^^xsd:string ;
    core:hasFacetCollection :ProductFacetCollection ;
    core:hasDataSource :DataSource .

  :DataSource a core:SparqlEndpoint ;
    core:location ""^^xsd:anyURI ;
    core:defaultGraph ""^^xsd:anyURI ;
    core:hasSparqlType core:VirtuosoSparql .

There are two definitions here. The first is just the s2s:SearchService, which gives some description of the service, and relates it to the FacetCollection and a DataSource. The second is the :DataSource definition. The FacetOntology metadata only tells us how to query the data, but it does not tell us where the is so it can actually be queried. That is the role of the :DataSource instance. There are various classes of data sources that are currently supported by S2S (see Creating Semantic Metadata for S2S), including RDF files, SPARQL 1.0 endpoints, and vendor specific endpoints such as Virtuoso (which is a special case for its proprietary SPARQL stuff). In the future, additional data sources should be added for GeoSPARQL, SPARQL 1.1, and other specifications that go beyond basic SPARQL 1.0.

For a more detailed example using some of the constructs below, see the BCO-DMO FacetOntology here:

Facet Ontology Extensions Properties

URI Domain Range Description
foe:contextpredicate facet:Facet facet:Predicate Adds predicate chains to context for results.
foe:sparqlSelectVariable facet:Facet xsd:string Informs the SPARQL grounding that additional variables must be selected from context.
foe:sparqlAggregateVariable facet:Facet xsd:string Informs the SPARQL grounding that additional variables should be included in a GROUP BY clause.
facet:labelpredicate facet:Facet facet:Predicate Simple modification to support predicate chains to labels.
foe:Filter N/A (owl:Class) N/A (owl:Class) Class added to contain information about filters for facets.
foe:filter facet:Facet foe:Filter Relates a facet to filters that should be applied to it.
foe:filtervalue foe:Filter xsd:string Specifies the actual constraint applied to filter results.
foe:transitive facet:Predicate xsd:boolean Notifies the SPARQL grounding that the predicate should be treated (or queried) as a transitive property.
foe:symmetric facet:Predicate xsd:boolean Notifies the SPARQL ground- ing that the predicate should be treated (or queried) as a sym- metric property.
foe:sparqlGraph facet:Predicate xsd:anyURI Specifies that a predicate should be queried from a specific named graph.
foe:sparqlBinding facet:Predicate xsd:string Specifies the variable that should be used for the predicate in a SPARQL query.
foe:codependent facet:Facet facet:Facet Specifies that two facets share a predicate path.
foe:optional facet:Predicate xsd:boolean Specifies that a predicate should be queries as optional.


Curie Namesapce