<docbook><section><title>VirtuosoFacetsWebServiceCustmExamples</title><title>Virtuoso Facets Web Service: Examples for customizing different types</title>Virtuoso Facets Web Service: Examples for customizing different types
<emphasis><emphasis>Note:</emphasis> In all examples from below the default namespace declaration: xmlns=&quot;<ulink url="http://openlinksw.com/services/facets/1.0/">http://openlinksw.com/services/facets/1.0/</ulink>&quot;, is omitted for brevity.</emphasis><bridgehead class="http://www.w3.org/1999/xhtml:h2">Examples</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">For people called Mike</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;view type=&quot;text&quot;/&gt;
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To open the list of people who Mike knows</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;view type=&quot;properties&quot;/&gt; 
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To show the list of subjects Mike knows</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;view type=&quot;list&quot; /&gt;
  &lt;/property&gt;
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To show the properties of people Mike knows</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;view type=&quot;properties&quot; /&gt;
  &lt;/property&gt; 
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To show the names</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;view type=&quot;list&quot; /&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To specify one named Joe</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
     &lt;property iri=&quot;[foaf:name]&quot;&gt;
        &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
     &lt;/property&gt;
    &lt;view type=&quot;properties&quot; /&gt;
  &lt;/property&gt; 
&lt;/query&gt;
</programlisting><para> This lists the properties of the friends of Mike that are called Joe.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To show the Mikes that know a Joe</bridgehead>
<para>To show the Mikes that know a Joe, one would change the shown variable in the navigation and get: </para>
<programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
   &lt;/property&gt; 
   &lt;view type=&quot;text&quot; /&gt; 
&lt;/query&gt;
</programlisting><para> This would be the search summaries of subjects with Mike in some field that know a subject with name Joe.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To specify that Mike must be a member of a discussion board</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;property iri=&quot;[foaf:knows]&quot;&gt;
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
     &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
   &lt;/property&gt;
  &lt;/property&gt; 
  &lt;view type=&quot;property-in&quot; /&gt; 
&lt;/query&gt;
</programlisting><para> This lists the properties of triples whom object is Mike.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To pick all sioc members</bridgehead>
 Pick sioc:member_of <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
    &lt;view type=&quot;list&quot; /&gt; 
  &lt;/property-of&gt; 
&lt;/query&gt;
</programlisting><para> This would show things where Mike is a member.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To specify that the thing must be a forum</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
    &lt;view type=&quot;classes&quot; /&gt; 
  &lt;/property-of&gt; 
&lt;/query&gt;
</programlisting><para> This shows classes of things where Mike is a member.</para>
<para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To specify sioc:Forum</bridgehead>
 Clicking on sioc:Forum gives: <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
    &lt;class iri=&quot;sioc:Forum&quot; /&gt; 
    &lt;view type=&quot;classes&quot;/&gt;  
  &lt;/property-of&gt;  
&lt;/query&gt;
</programlisting><para> The view stays with classes, but now scoped to the classes of things where Mike is a member that are instances of sioc:Forum.</para>
<para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To look at the list of Mikes with the added restriction</bridgehead>
 To go look at the list of Mikes with the added restriction, click the shown variable in the navigation and set it to s1.
<programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
   &lt;class iri=&quot;sioc:Forum&quot; /&gt; 
  &lt;/property-of&gt; 
  &lt;view type=&quot;list&quot;/&gt; 
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">To say that Joe must also have a geekCode</bridgehead>
 To say that Joe must also have a geekCode, one clicks the shown variable and sets it to s2 and the view to properties.
<programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
    &lt;view type=&quot;properties&quot;/&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
    &lt;class iri=&quot;sioc:Forum&quot; /&gt; 
   &lt;/property-of&gt;  
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Pick geekCode</bridgehead>
 <programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
    &lt;property iri=&quot;geekCode&quot;&gt;
      &lt;view type=&quot;list&quot;/&gt;
    &lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt;
    &lt;class iri=&quot;sioc:Forum&quot; /&gt; 
  &lt;/property-of&gt;  
&lt;/query&gt;
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h3">To take the focus back to Mike</bridgehead>
 We specify no restriction on the geekCode.
 Click the shown variable to take the focus back to Mike.
<programlisting>&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt; 
  &lt;property iri=&quot;[foaf:knows]&quot;&gt; 
    &lt;property iri=&quot;[foaf:name]&quot;&gt;
      &lt;value datatype=&quot;string&quot;&gt;Joe&lt;/value&gt;
    &lt;/property&gt;
    &lt;property iri=&quot;geekCode&quot;&gt;&lt;/property&gt;
  &lt;/property&gt; 
  &lt;property-of iri=&quot;sioc:member_of&quot;&gt; 
    &lt;class iri=&quot;sioc:Forum&quot; /&gt; 
  &lt;/property-of&gt;   
  &lt;view type=&quot;text&quot;/&gt; 
&lt;/query&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Looking up property count</bridgehead>
 <programlisting>curl -H &quot;Content-Type: text/xml&quot; -d @post.xml  http://lod.openlinksw.com/fct/service
</programlisting><para> Where &#39;post.xml&#39; document contains query document: </para>
<programlisting>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;property iri=&quot;[foaf:knows]&quot;&gt;
    &lt;view type=&quot;list-count&quot; limit=&quot;20&quot; /&gt;
  &lt;/property&gt;
&lt;/query&gt;
</programlisting><para> Produces the <ulink url="VirtuosoFacetsWebServiceCustmExamplesEx1">following response</ulink>.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Looking up instances of a class</bridgehead>
 <programlisting>curl -H &quot;Content-Type: text/xml&quot; -d @post.xml  http://lod.openlinksw.com/fct/service
</programlisting><para> Where &#39;post.xml&#39; document contains query document: </para>
<programlisting>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;query&gt;
  &lt;text&gt;Mike&lt;/text&gt;
  &lt;class iri=&quot;[foaf:Person]&quot;/&gt;
  &lt;view type=&quot;list&quot; limit=&quot;10&quot; /&gt;
&lt;/query&gt;
</programlisting><para> Produces the <ulink url="VirtuosoFacetsWebServiceCustmExamplesEx2">following response</ulink>.</para>
<emphasis><emphasis>Note:</emphasis> If the entire &lt;text&gt; 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: </emphasis> <programlisting>&lt;query&gt;
  &lt;property iri=&quot;[foaf:knows]&quot;&gt;
    &lt;view type=&quot;properties&quot; limit=&quot;20&quot; offset=&quot;0&quot;/&gt;
  &lt;/property&gt;
&lt;/query&gt;
</programlisting><para> <emphasis>is executed as:</emphasis> </para>
<programlisting>SELECT  ?s2p AS ?c1 
        COUNT (*) AS ?c2  
WHERE
   { 
     ?s1  &lt;http://xmlns.com/foaf/0.1/knows&gt;  ?s2  . 
     ?s2  ?s2p  ?s2o  . 
   } 
GROUP BY ?s2p 
ORDER BY DESC 2 
LIMIT 20
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h2">Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem>Facets Web Service: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtuosoFacetsWebService">Virtuoso Facets Web Service</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Linked Data: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtuosoFacetsViewsLinkedData">Faceted Views over Large-Scale Linked Data</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Facet Browser Installation and configuration: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtFacetBrowserInstallConfig">Virtuoso Facet Browser Installation and configuration</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Facet APIs: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtFacetBrowserAPIs">Virtuoso APIs for FCT REST services</ulink> </listitem>
<listitem><ulink url="VirtFacetBrowserAPIsFCTEXEC"><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikifct_exec</span> API Example</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Pivot Viewer and CXML: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtSparqlCxmlFacetPivotBridge#AncSparqlCxmlFacetPivotBridge">Facet Pivot Bridge -  A bridge to PivotViewer from Virtuoso&#39;s Faceted query service for RDF</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtSparqlCxml#AncFacetTypeAutoDetection">Auto-Detection of Facet Type</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Tutorials: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtuosoLODSampleTutorial">Faceted Browsing Sample using LOD Cloud Cache data space</ulink> </listitem>
<listitem><ulink url="VirtuosoFacetsWebServiceSOAPExample">SOAP Facets Example</ulink> </listitem>
<listitem><ulink url="VirtFacetBrowserInstallConfigQueried">Querying The Facet Browser Web Service endpoint</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtVisualizeWithPivotViewer#GenFCT">Visualizing Your Data With PivotViewer Using The Facet Browser</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksCustomControlLabelsURI">Custom Controlling Virtuoso Labels for URI functionality Example</ulink> </listitem>
<listitem><ulink url="VirtuosoFacetsWebServiceChoiceExample">Facets Web Service: Choice of Labels Example</ulink> </listitem>
</itemizedlist></listitem>
<listitem>Downloads: <itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://shop.openlinksw.com/license_generator/virtuoso-download/">Latest Virtuoso</ulink> </listitem>
<listitem><ulink url="https://virtuoso.openlinksw.com/download/">Virtuoso Facet Browser VAD package</ulink></listitem>
</itemizedlist></listitem>
</itemizedlist></section></docbook>