IWSearch Tutorial


1. How to query IWSearch

Step 1: obtain the URL of IWSearch

        http://onto.rpi.edu/iwsearch/iwsearch?

Example Java code
        String szService = "http://onto.rpi.edu/iwsearch/iwsearch?";

Step 2: specify query params


Params
Meaning
Value Range
Example Value
usesSearchService the choice of specific servics provided by IWSearch, we only have one service right now
{search_pml_instance}
[note1]

search_pml_instance
hasSearchString the search string to be run on the search index URL-Encoded String
[note2]
type:Person
usesSearchResultSyntax the choice of syntax for encoding the reponse generated by IWSearch {HTML,RDFXML, N3,NT}
[note3]
RDFXML


[Note1]: search http://inference-web.org/2007/10/service/iwsearch.owl for instances of search:SearchService

[Note2]: you may use java.net.URLEncode to encode  the search string when you
        URLEncoder.encode( your_string, "UTF-8")

[Note3]: search http://inference-web.org/2007/10/service/archive.owl for instances of  pmlp:Language

Example Java code
        String szQuery ="";
        szService += "usesSearchService="+"search_pml_instance";
        szService += "hasSearchString="+URLEncoder.encode("type:Person");
        szService += "usesSearchResultSyntax="+"RDFXML";

Step 3: generate the URL for querying IWSearch 

the serach result will be returned as HTTP response to this URL

 http://onto.rpi.edu/iwsearch/iwsearch?usesSearchService=search_pml_instance&usesSearchResultSyntax=html&hasSearchString=type:Person

Examlple Java code:
       String url =  szService+ szQuery;

Step 4: parse the returned Document and get the result

SearchResponse
Params
Meaning
Value Range
Example Value
isSearchSucceed whether the search is succeed {true, false} true
hasSearchTotalResults the total matching results non-negative integer 18
hasSearchRequest the request generating this reponse instance of SearchRequest n/a
hasSearchProcessSeconds the number of seconds for processing this query float 0.332

InstanceMetadata: the search result for  (search_pml_instance), each PML instance's metadata is stroed in one instance of InstanceMetadata.
Params
Meaning
Value Range
Example Value
rdfs:label the name of thePML instance String Deborah L. McGuinness
dc:identifier the URI of the PML instance URI http://inference-web.org/registry/PER/DLM.owl#DLM
dc:source the source publishing the PML instance URI http://inference-web.org/registry/PER/DLM.owl
dc:date when the metadata about this  PML instance has been indexed Date 2007-05-30T09:30:10Z

Note: you may want to use jena to parse the search result

Example Java Code:
       Model m  = ModelFactory.createDefaultModel();
        m.read(url);
        // check if the results
        Iterator iter = m.listSubjectsWithProperty(RDF.type, IWSEARCH.InstanceMetadata );
        while (iter.hasNext()){
                Resource subject = (Resource) iter.next();

                // get the metadata about this resource
                String label = getAttributeValue(m, subject, RDFS.label);
                String uri  = getAttributeValue(m, subject, DC.identifier);
                String source  = getAttributeValue(m, subject, DC.source);
                String date = getAttributeValue(m, subject, DC.date);
        }
       
        String getAttributeValue(Model m, Resource subject, Property property){
                 Iterator iter = m.listObjectsOfProperty(subject, property);
                if (iter.hasNext()){
                    RDFNode value = (RDFNode) iter.next();
                    if (value.isURIResource()){
                        return ((Resource)value).getURI();
                    }else if (value.isLiteral()){
                        return ((Literal)value).getString();
                    }
                }
                return null;                      
        }   
Notes: The example java code is ExampleIWSearchClient.java. It depends on JENA library and a vocabulary file IWSEARCH.java.
This page was last updated by