LOC-6: Isbn indexes for instances
[mp-sparql-moved-to-github.git] / bibframe / triplestore.xml
index 28f34c0..7fd29fd 100644 (file)
 
             <!-- bf.uri is a simple way to get to a thing -->
             <index type="bf.uri">
-                ?thing  rdf:type ?any FILTER( ?thing  = %u ) </index>
+                ?thing  rdf:type ?any FILTER( ?thing  = %u )
+            </index>
 
+            <!-- bf.type is a simple way to search for types -->
+            <!-- for example, a bf.Work can also be bf:Text or bf:Audio -->
+            <index type="bf.type">
+                ?thing  a %t
+            </index>
 
             <!-- The BF-L present format is the same for everything -->
-            <!-- Each db is supposed to provide a dedicated BF-F present format -->
+            <!-- Each db is supposed to provide a dedicated BF-V present format -->
             <present type="BF-L">
                 CONSTRUCT {
-                    ?thing ?rel ?subj
+                    %u ?rel ?subj
                 }
                 WHERE {
-                    ?thing ?rel ?subj .
-                    ?thing ?rel ?subj FILTER( str(?thing) = %s )
+                    %u ?rel ?subj .
                 }
             </present>
 
 
             <!-- Combined title index. There are so many ways titles can be expresses
             in Bibframe, this seems to cover most of what we have seen -->
-            <!-- TODO - See the anytitle in instance for a more flexible way -->
             <index type="bf.anytitle">
                 {
-                    ?thing bf:workTitle ?wt .
-                    { ?wt bf:titleValue %v FILTER(contains(%v, %s)) } UNION
-                    { ?wt bf:subtitle %v FILTER(contains(%v, %s)) } UNION
-                    { ?wt bf:partTitle %v FILTER(contains(%v, %s)) }
-                } UNION {
-                    ?thing bf:titleVariation ?tv .
-                    ?tv bf:titleValue %v FILTER(contains(%v, %s))
+                    ?thing bf:title %v FILTER(contains(%v, %s))
+                } UNION { <!-- any kind of link -->
+                    ?thing ?titlerel ?ti . <!-- mostly workTitle, but others too -->
+                    ?ti a bf:Title <!-- to something that is a title -->
+                    {
+                        ?ti bf:titleValue %v FILTER(contains(%v, %s))
+                    } UNION {
+                        ?ti bf:partTitle %v FILTER(contains(%v, %s))
+                    } UNION {
+                        ?ti bf:subtitle %v FILTER(contains(%v, %s))
+                    }
                 } UNION {
                     ?inst bf:instanceOf ?thing .
                     ?inst bf:instanceTitle ?it .
                     ?it bf:titleValue %v FILTER(contains(%v, %s))
                 } UNION {
-                    ?thing bf:title %v FILTER(contains(%v, %s))
                 }
             </index>
 
                 ?subject bf:label %v FILTER(contains(%v, %s))
             </index>
 
+            <!-- contentCategory can be searched with complete URIs like -->
+            <!-- http://id.loc.gov/vocabulary/contentTypes/txt -->
+            <index type="bf.contentcategory">
+                ?thing bf:contentCategory %u
+            </index>
 
             <!-- Present formats -->
             <!-- BF-L comes from the "thing" template -->
-            <!-- BF-F expands all links, except to instances and other works -->
-            <present type="BF-F">
-                CONSTRUCT {
-                    ?thing ?rel ?obj .
-                    ?obj ?rel1 ?obj1 .
-                    ?obj1 ?rel2 ?obj2 .
-                    ?obj2 ?rel3 ?obj3
-                }
-                WHERE {
-
-                    ?thing a bf:Work .
-                    ?thing ?rel ?obj .
-                    OPTIONAL {
-                        ?obj ?rel1 ?obj1
-                        MINUS { ?obj a bf:Work }
-                        MINUS { ?obj a bf:Instance }
-                    }
-                    OPTIONAL {
-                        ?obj1 ?rel2 ?obj2
-                        MINUS { ?obj1 a bf:Work }
-                        MINUS { ?obj1 a bf:Instance }
-                    }
-                    OPTIONAL {
-                        ?obj2 ?rel3 ?obj3
-                        MINUS { ?obj2 a bf:Work }
-                        MINUS { ?obj2 a bf:Instance }
-                    }
-                    ?thing ?rel ?obj FILTER( str(?thing) = %s )
-                    <!-- TODO Use the %u -->
-                    <!-- TODO Use the BF-FI as the BF-F -->
-                }
-            </present>
-
-            <!-- full, with instances. Experimental! -->
-            <present type="BF-FI">
+            <!-- BF-V expands all links, even to instances but not other works -->
+            <present type="BF-V">
                 CONSTRUCT {
-                    %u ?rel ?wobj1 .
-                    ?wobj1 ?wrel1 ?wobj2 .
-                    ?wobj2 ?wrel2 ?wobj3 .
+                    %u ?wrel1 ?wobj1 .
+                    ?wobj1 ?wrel2 ?wobj2 .
+                    ?wobj2 ?wrel3 ?wobj3 .
                     ?inst ?irel1 ?iobj1 .
                     ?iobj1 ?irel2 ?iobj2 .
                     ?iobj2 ?irel3 ?iobj3
                 }
                 WHERE {
                     %u a bf:Work .
-                    %u ?rel ?wobj1 .
+                    %u ?wrel1 ?wobj1 .
 
                     OPTIONAL {
-                        ?wobj ?wrel1 ?wobj1
-                        MINUS { ?wobj a bf:Work }
-                        MINUS { ?wobj a bf:Instance }
-                    }
-                    OPTIONAL {
                         ?wobj1 ?wrel2 ?wobj2
-                        MINUS { ?wobj1 a bf:Work }
-                        MINUS { ?wobj1 a bf:Instance }
-                    }
-                    OPTIONAL {
-                        ?wobj2 ?wrel3 ?wobj3
-                        MINUS { ?wobj2 a bf:Work }
-                        MINUS { ?wobj2 a bf:Instance }
+                            MINUS { ?wobj1 a bf:Work }
+                            MINUS { ?wobj1 a bf:Instance }
+                        OPTIONAL {
+                            ?wobj2 ?wrel3 ?wobj3
+                                MINUS { ?wobj2 a bf:Work }
+                                MINUS { ?wobj2 a bf:Instance }
+                        }
                     }
-
                     <!-- Link to the instance(s) -->
                     OPTIONAL {
-                        ?inst bf:instanceOf %u
-                    }
-                    <!-- and expand the instance -->
-                    OPTIONAL {
+                        ?inst bf:instanceOf %u .
                         ?inst ?irel1 ?iobj1
-                    }
-                    OPTIONAL {
-                        ?iobj1 ?irel2 ?iobj2
-                    }
-                    OPTIONAL {
-                        ?iobj2 ?irel3 ?iobj3
+                        OPTIONAL {
+                            ?iobj1 ?irel2 ?iobj2
+                                MINUS { ?iobj1 a bf:Work }
+                                MINUS { ?iobj1 a bf:Instance }
+                            OPTIONAL {
+                                ?iobj2 ?irel3 ?iobj3
+                                    MINUS { ?iobj2 a bf:Work }
+                                    MINUS { ?iobj2 a bf:Instance }
+                            }
+                        }
                     }
                 }
             </present>
 
         <!-- Instance database -->
 
-        <db path="instance" schema="sparql-results" include="thing">
+        <db path="instance" schema="sparql-results" include="thing smallindex">
             <criteria>?thing a bf:Instance</criteria>
 
             <!-- Title indexes -->
                 }
             </index>
 
-            <!-- Presetn formats. BF-L comes from "thing" -->
+            <!-- isbn index. The Instance may contain a isbn10 or isbn13. -->
+            <!-- These can be literal values like -->
+            <!--   http://isbn.example.org/1906833214 which we need to search -->
+            <!-- by our usual substring match. Or they can be links to Identivfiers -->
+            <!-- which will have a proper identifierValue on which we can do -->
+            <!-- an exact match -->
+            <index type="bf.isbn">
+                {
+                    ?thing bf:isbn10  %v
+                        FILTER(contains(str(%v), %s))
+                } UNION {
+                    ?thing bf:isbn13  %v
+                        FILTER(contains(str(%v), %s))
+                } UNION {
+                    {
+                        ?thing bf:isbn10 ?isbn
+                    } UNION {
+                        ?thing bf:isbn13 ?isbn
+                    }
+                    ?isbn a bf:Identifier  .
+                    ?isbn bf:identifierValue  %v FILTER( %v = %s )
+                }
+            </index>
+
+
+            <!-- Present formats. BF-L comes from "thing" -->
             <!-- Full instance, with the related work too -->
-            <present type="BF-F">
+            <present type="BF-V">
                 CONSTRUCT {
                     %u ?irel1 ?iobj1 .
                     ?iobj1 ?irel2 ?iobj2 .
                 }
                 WHERE {
                     %u a bf:Instance .
-                    %u ?irel1 ?iobj1
+                    %u ?irel1 ?iobj1 .
                     OPTIONAL {
                         ?iobj1 ?irel2 ?iobj2
-                        MINUS { ?iobj1 a bf:Work }
-                        MINUS { ?iobj1 a bf:Instance }
+                            MINUS { ?iobj2 a bf:Work }
+                            MINUS { ?iobj2 a bf:Instance } .
                         OPTIONAL {
                             ?iobj2 ?irel3 ?iobj3
-                            MINUS { ?iobj2 a bf:Work }
-                            MINUS { ?iobj2 a bf:Instance }
+                                MINUS { ?iobj3 a bf:Work }
+                                MINUS { ?iobj3 a bf:Instance }
                         }
                     }
-
-                    OPTIONAL {
-                        %u bf:instanceOf ?work
+                    OPTIONAL { <!-- Work -->
+                        %u bf:instanceOf ?work .
+                        ?work ?wrel1 ?wobj1 .
                         OPTIONAL {
-                            ?work ?wrel1 ?wobj1
-                            MINUS { ?wobj1 a bf:Work }
-                            MINUS { ?wobj1 a bf:Instance }
+                            ?wobj1 ?wrel2 ?wobj2
+                                MINUS { ?wobj1 a bf:Work }
+                                MINUS { ?wobj1 a bf:Instance } .
                             OPTIONAL {
-                                ?wobj1 ?wrel2 ?wobj2
-                                MINUS { ?wobj2 a bf:Work }
-                                MINUS { ?wobj2 a bf:Instance }
-                                OPTIONAL {
-                                    ?wobj2 ?wrel3 ?wobj3
-                                    MINUS { ?wobj3 a bf:Work }
-                                    MINUS { ?wobj3 a bf:Instance }
-                                }
+                                ?wobj2 ?wrel3 ?wobj3
+                                    MINUS { ?wobj2 a bf:Work }
+                                    MINUS { ?wobj2 a bf:Instance }
                             }
                         }
                     }
         <!-- but have different "any" indexes -->
 
         <db path="smallbody" include="thing">
-            <present type="BF-F">
+            <present type="BF-V">
                 <!-- I don't think we need more than one level -->
                 <!--for these simple databases -->
                 CONSTRUCT {