Refining queries

I'm using Stardog Studio (online) to query an ontology developed as part of a research project. I have a series of queries that I use to answer specific questions. I want to further refine the results of my queries so it only includes the results that are under a specific sub-class of the ontology. However, I can't find where I should be looking in the Stardog documentation to figure out how to do this or what commands can help me do this.

I do see that the particular elements I want are in the CSV file (using run to file). And I know that these elements are all subclasses of a particular class in my ontology. So they are there, they are in the results. So I'm not sure how this is called but I want to get only the answers that correspond to the particular leaves of a specific branch of the ontology if this makes sense.

Can you share your queries and possibly your data or at least an example of it?

Yes of course. Here is the query I'm using now:

prefix stardogapi: <tag:stardog:api:>

select ?entity ?doc ?mention ?type ?label where 
{
    ?doc stardogapi:property:textMatch 

    "System Security Analyst" ,    
    "Application isolation will limit what other processes and system features the exploited target can access.",
    "Web Application Firewalls may be used to limit exposure of applications to prevent exploit traffic from reaching the application.",
    "Segment externally facing servers and services from the rest of the network with a DMZ or on separate hosting infrastructure.",
    "Use least privilege for service accounts will limit what permissions the exploited process gets on the rest of the system.",
    "Regularly scan externally facing systems for vulnerabilities and establish procedures to rapidly patch systems when critical vulnerabilities are discovered through scanning and through public disclosure.",
    "Regularly scan externally facing systems for vulnerabilities and establish procedures to rapidly patch systems when critical vulnerabilities are discovered through scanning and through public disclosure.".

  graph ?doc
  {
       ?doc stardog:docs:hasEntity ?entity .
       ?entity <http://purl.org/dc/terms/references> ?mention
   }
   ?mention a ?type ; rdfs:label ?label
}
Order by ?doc

Here is an example of the output in the attached file
Scenarios_validation_Q1_sparql_results.csv.zip (8.3 KB)

I'm hoping to have a result that would only have the last column (label) would match the labels in a specific 'branch' of my ontology, which contains work roles. Of course, this is the ontology that is loaded in the Stardog database.

Try changing your ?mentino a ?type clause to ?mention rdf:subClassOf <branchRootClass>. You most likely will need to turn on reasoning.

Did you want the full text search evaluated as an 'or' or an 'and' over those terms? It may be more efficient to evaluate that with a single argument textMatch and use Lucene operators rather than separate calls.

OK, thank you, I'll try this right away and post the result

SO I did replace ?mention a ?type with this:

?mention rdf:subClassOf http://webprotege.stanford.edu/R9UCBFUhVeYdw3whoZIy9xc.

In this case there are no results.

The IRI I show here is the root class of the subclass from where I what to limit the answers from. Maybe this information will help to help me... When I run the query as before I get 633 results, including the results where the label is in the group I want, being under the subclass mentioned above.

My mistake. rdfs:subClassOf (rdfs prefix not rdf. Stupid autocorrect)

Zachary, We have liftoff !

prefix fts: tag:stardog:api:property:textmatch:
prefix stardogapi: tag:stardog:api:

select ?entity ?doc ?mention ?type ?label where
{
?doc stardogapi:property:textMatch

"System Security Analyst" ,    

"Application isolation will limit what other processes and system features the exploited target can access.",
"Web Application Firewalls may be used to limit exposure of applications to prevent exploit traffic from reaching the application.",
"Segment externally facing servers and services from the rest of the network with a DMZ or on separate hosting infrastructure.",
"Use least privilege for service accounts will limit what permissions the exploited process gets on the rest of the system.",
"Regularly scan externally facing systems for vulnerabilities and establish procedures to rapidly patch systems when critical vulnerabilities are discovered through scanning and through public disclosure.",
"Regularly scan externally facing systems for vulnerabilities and establish procedures to rapidly patch systems when critical vulnerabilities are discovered through scanning and through public disclosure.".

graph ?doc
{
?doc stardog:docs:hasEntity ?entity .
?entity http://purl.org/dc/terms/references ?mention
}
?mention rdfs:subClassOf http://webprotege.stanford.edu/R9UCBFUhVeYdw3whoZIy9xc ; rdfs:label ?label .
}

This worked !!! and the results look exactly as what I expected. Thank you for this, I'll be able to move forward.

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