Search string in Stardog Explorer

Hello,

I have a basic question related to the Stardog Explorer search string.

I have done the following

  1. Created a Database using Studio
  2. Created the Model using Studio
  3. Created the mapping file and generated the Virtual Graph
  4. Enabled Virtual Transparency option in the DB properties
  5. Then Visualized the graph using Explorer

Everything seems working fine, but the only thing bothering is, every time I have to search for something then I have to provide the entire URI prefix to the Search keyword, like shown below. If I search only for the keyword then it is not fetching any result. Any idea what am I missing here? Please find below the snapshot of the Explorer

Mapping File (Partial):

PREFIX : <http://example.com/DNA/KG/Sample/>
PREFIX Sample: <http://example.com/DNA/KG/Sample/>
PREFIX rr: <http://www.w3.org/ns/r2rml#>

MAPPING
FROM SQL {
  SELECT "country_id", "country_name", "location_currency"
  FROM "public"."location"
  GROUP BY "country_id", "country_name", "location_currency"
}
TO {
  ?subject Sample:has_currency ?has_currency .
  ?subject Sample:has_name ?country_name .
  ?subject rdf:type Sample:Country
} WHERE {
  BIND(template("http://example.com/DNA/KG/Sample/{country_id}") AS ?subject)
  BIND(template("http://example.com/DNA/KG/Sample/{location_currency}") AS ?has_currency)
}
;

Model

@prefix : <http://api.stardog.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix stardog: <tag:stardog:api:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix Location: <http://example.com/DNA/KG/Sample/> .

Location:Currency a owl:Class ;
    <tag:stardog:studio:label> "Currency" ;
    rdfs:label "Currency" ;
    rdfs:comment "Currency" .

Location:Country a owl:Class ;
    <tag:stardog:studio:label> "Country" ;
    rdfs:label "Country" ;
    rdfs:comment "Country" ;
    rdfs:subClassOf owl:Thing .

Location:Region a owl:Class ;
    <tag:stardog:studio:label> "Region" ;
    rdfs:label "Region" ;
    rdfs:comment "Region" ;
    rdfs:subClassOf Location:Country .

Hi Muthu,

To enable search for a virtual source you must also define one of the properties Explorer searches against. These properties include: http://www.w3.org/2000/01/rdf-schema#comment, http://www.w3.org/2000/01/rdf-schema#label, http://www.w3.org/2004/02/skos/core#definition, and http://www.w3.org/2004/02/skos/core#prefLabel (docs link, Stardog Explorer | Stardog Documentation Latest).

For instance, if you expanded your mapping to include rdfs:label for the country code, Country codes can be searched directly. Such as BR versus searching for the full IRI.

Example update to your partial mapping file:

PREFIX : <http://example.com/DNA/KG/Sample/>
PREFIX Sample: <http://example.com/DNA/KG/Sample/>
PREFIX rr: <http://www.w3.org/ns/r2rml#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

MAPPING
FROM SQL {
  SELECT "country_id", "country_name", "location_currency"
  FROM "public"."location"
  GROUP BY "country_id", "country_name", "location_currency"
}
TO {
  ?subject Sample:has_currency ?has_currency .
  ?subject Sample:has_name ?country_name .
  ?subject rdfs:label ?country_name .
  ?subject rdf:type Sample:Country
} WHERE {
  BIND(template("http://example.com/DNA/KG/Sample/{country_id}") AS ?subject)
  BIND(template("http://example.com/DNA/KG/Sample/{location_currency}") AS ?has_currency)
}
;

Please note that for virtual sources we only support starts with and ends with patterns as we don't support full-text search over virtual sources.

1 Like

Thank you so much Laura. This is very helpful, now it is working as expected. :blush:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.