• Topic
  • Discussion
  • VOS.VirtuosoFacetsWebServiceCustmExamples(Last) -- Owiki? , 2018-04-13 12:10:27 Edit owiki 2018-04-13 12:10:27

    Virtuoso Facets Web Service: Examples for customizing different types

    Note: In all examples from below the default namespace declaration: xmlns="http://openlinksw.com/services/facets/1.0/", is omitted for brevity.

    Examples

    For people called Mike


    <query>
      <text>Mike</text>
      <view type="text"/>
    </query>
    

    To open the list of people who Mike knows


    <query>
      <text>Mike</text>
      <view type="properties"/> 
    </query>
    

    To show the list of subjects Mike knows


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <view type="list" />
      </property>
    </query>
    

    To show the properties of people Mike knows


    <query>
      <text>Mike</text>
      <property iri="[foaf:knows]"> 
        <view type="properties" />
      </property> 
    </query>
    

    To show the names


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <view type="list" />
        </property>
      </property> 
    </query>
    

    To specify one named Joe


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
         <property iri="[foaf:name]">
            <value datatype="string">Joe</value>
         </property>
        <view type="properties" />
      </property> 
    </query>
    

    This lists the properties of the friends of Mike that are called Joe.

    To show the Mikes that know a Joe

    To show the Mikes that know a Joe, one would change the shown variable in the navigation and get:


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
       </property> 
       <view type="text" /> 
    </query>
    

    This would be the search summaries of subjects with Mike in some field that know a subject with name Joe.

    To specify that Mike must be a member of a discussion board


    <query>
      <text>Mike</text>
      <property iri="[foaf:knows]">
        <property iri="[foaf:name]">
         <value datatype="string">Joe</value>
       </property>
      </property> 
      <view type="property-in" /> 
    </query>
    

    This lists the properties of triples whom object is Mike.

    To pick all sioc members

    Pick sioc:member_of
    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
      </property> 
      <property-of iri="sioc:member_of"> 
        <view type="list" /> 
      </property-of> 
    </query>
    

    This would show things where Mike is a member.

    To specify that the thing must be a forum


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
      </property> 
      <property-of iri="sioc:member_of"> 
        <view type="classes" /> 
      </property-of> 
    </query>
    

    This shows classes of things where Mike is a member.

    To specify sioc:Forum

    Clicking on sioc:Forum gives:
    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
      </property> 
      <property-of iri="sioc:member_of"> 
        <class iri="sioc:Forum" /> 
        <view type="classes"/>  
      </property-of>  
    </query>
    

    The view stays with classes, but now scoped to the classes of things where Mike is a member that are instances of sioc:Forum.

    To look at the list of Mikes with the added restriction

    To go look at the list of Mikes with the added restriction, click the shown variable in the navigation and set it to s1.
    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
      </property> 
      <property-of iri="sioc:member_of"> 
       <class iri="sioc:Forum" /> 
      </property-of> 
      <view type="list"/> 
    </query>
    

    To say that Joe must also have a geekCode

    To say that Joe must also have a geekCode, one clicks the shown variable and sets it to s2 and the view to properties.
    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
        <view type="properties"/>
      </property> 
      <property-of iri="sioc:member_of"> 
        <class iri="sioc:Forum" /> 
       </property-of>  
    </query>
    

    Pick geekCode


    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
        <property iri="geekCode">
          <view type="list"/>
        </property>
      </property> 
      <property-of iri="sioc:member_of">
        <class iri="sioc:Forum" /> 
      </property-of>  
    </query>
    

    To take the focus back to Mike

    We specify no restriction on the geekCode. Click the shown variable to take the focus back to Mike.
    <query>
      <text>Mike</text> 
      <property iri="[foaf:knows]"> 
        <property iri="[foaf:name]">
          <value datatype="string">Joe</value>
        </property>
        <property iri="geekCode"></property>
      </property> 
      <property-of iri="sioc:member_of"> 
        <class iri="sioc:Forum" /> 
      </property-of>   
      <view type="text"/> 
    </query>
    

    Looking up property count


    curl -H "Content-Type: text/xml" -d @post.xml  http://lod.openlinksw.com/fct/service
    

    Where 'post.xml' document contains query document:


    <?xml version="1.0"?>
    <query>
      <text>Mike</text>
      <property iri="[foaf:knows]">
        <view type="list-count" limit="20" />
      </property>
    </query>
    

    Produces the following response.

    Looking up instances of a class


    curl -H "Content-Type: text/xml" -d @post.xml  http://lod.openlinksw.com/fct/service
    

    Where 'post.xml' document contains query document:


    <?xml version="1.0"?>
    <query>
      <text>Mike</text>
      <class iri="[foaf:Person]"/>
      <view type="list" limit="10" />
    </query>
    

    Produces the following response.

    Note: If the entire <text> element is missing, the FCT service will not add a bif:contains to the triple pattern. Thus it is possible to search for some property or class, etc. For example:
    <query>
      <property iri="[foaf:knows]">
        <view type="properties" limit="20" offset="0"/>
      </property>
    </query>
    

    is executed as:


    SELECT  ?s2p AS ?c1 
            COUNT (*) AS ?c2  
    WHERE
       { 
         ?s1  <http://xmlns.com/foaf/0.1/knows>  ?s2  . 
         ?s2  ?s2p  ?s2o  . 
       } 
    GROUP BY ?s2p 
    ORDER BY DESC 2 
    LIMIT 20
    

    Related