I'm using Protege-5.0.0-beta-17
to develop an ontology and apache-jena-fuseki-2.0.0
to host the ontology. It has following individuals. Background of this scenario is that there are policy individuals under http://mywebsite.com/module/ontologies/local_policy
. Basically policies are type of the local_policies.
<!-- http://mywebsite.com/module/ontologies/policy1 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy1">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">1.1.1</PolicyName>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyKeyword rdf:datatype="&xsd;string">Information Security</PolicyKeyword>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Interactive-Information</PolicyMaturityLevel>
<PolicyConsulted rdf:datatype="&xsd;string">CERT</PolicyConsulted>
<PolicyDesc rdf:datatype="&xsd;string">The relevant sections of Information Security Policy which has been published by government should be used for classifying organizational data and information. The particular policies have been elaborated in "Information assets classification and control" of the Information Security (IS) policy (http://www.government.lk/images/secPolicy/Asset_Classification_and_Control.doc). The Assistance of Computer Emergency Readiness Team (CERT) could be obtained for this purpose.</PolicyDesc>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea1"/>
</owl:NamedIndividual>
<!-- http://mywebsite.com/module/ontologies/policy2 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy2">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">2</PolicyName>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyKeyword rdf:datatype="&xsd;string">Information Security</PolicyKeyword>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Interactive-Information</PolicyMaturityLevel>
<PolicyConsulted rdf:datatype="&xsd;string">CERT</PolicyConsulted>
<PolicyDesc rdf:datatype="&xsd;string">The policies defined under the “Privacy and Citizen Information Protection” of the IS policy which have been published by government should be implemented. The guidelines provided in the above section of IS policy could be accessed through (http://www.government.lk/images/secPolicy/Privacy__Citizen_Information_Protection.doc). The assistance of CERT could be obtained for achieving this purpose.</PolicyDesc>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea2"/>
</owl:NamedIndividual>
<!-- http://mywebsite.com/module/ontologies/policy3 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy3">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">3</PolicyName>
<PolicyDesc rdf:datatype="&xsd;string">A matrix could be defined for identifying all possible audience and possible delivery channels of organizational data/information. The template given in Annex 001 could be used for this purpose. (refer Annex 001 – Information/Data classification matrix)</PolicyDesc>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyConsulted rdf:datatype="&xsd;string">government</PolicyConsulted>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Initial Infomration</PolicyMaturityLevel>
<PolicyKeyword rdf:datatype="&xsd;string">Service Delivery Channels</PolicyKeyword>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea3"/>
</owl:NamedIndividual>
What I'm trying to do is query the ontology and fetch the these individuals. Also note that there are other individuals as well. Below is the query I'm using.
SELECT ?s
WHERE
{
?s ?p ?o
FILTER(REGEX(?o, "policy"))
}
But it does nt fetch the individuals as expected.
<http://mywebsite.com/module/ontologies/policy2>
<http://mywebsite.com/module/ontologies/policy1>
How can I do a full text search across all the owl:NamedIndividual
and if there is a matching return the particular matching owl:NamedIndividual
with all the data?
What I'm trying to do here is when a user type policy
I want to fetch all the policies where it contains policy keyword. Let's assume that a user type security
if so I want to fetch all the owl:NamedIndividual
which contains keyword security
. Also it should be type of local_policy as shown below.
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
If you want to retrieve elements of type http://mywebsite.com/module/ontologies/local_policy, then you'll need to ask for those:
select * where {
?s rdf:type <http://mywebsite.com/module/ontologies/local_policy>
}
If you then want to ensure that they have some property with a value whose string representation contains the text policy, you'd add an appropriate filter. E.g.:
select distinct ?s where {
?s ?p ?o ;
a <http://mywebsite.com/module/ontologies/local_policy>
filter contains(lcase(str(?o)),"security")
}
If you want to get all the properties and values of the individuals, just select the ?p and ?o variables as well:
select distinct ?s ?p ?o where {
?s ?p ?o ;
a <http://mywebsite.com/module/ontologies/local_policy>
filter contains(lcase(str(?o)),"security")
}
You could also use a construct query to get those triples back as a new model:
construct where {
?s ?p ?o ;
a <http://mywebsite.com/module/ontologies/local_policy>
filter contains(lcase(str(?o)),"security")
}