LOC-6: Isbn indexes for instances
[mp-sparql-moved-to-github.git] / bibframe / triplestore.xml
index 633d9d5..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-V present format -->
                 ?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-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 {
                         ?wobj1 ?wrel2 ?wobj2
                 }
             </index>
 
+            <!-- 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-V">