- <filter type="sparql">
- <!-- Which sparql server to use, our demo, or your local installation -->
- <!--defaults uri="http://bibframe.indexdata.com/sparql/"/-->
- <defaults uri="http://localhost:8890/sparql/"/>
-
- <!-- work database -->
- <db path="work" schema="sparql-results">
- <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
- <prefix>bf: http://bibframe.org/vocab/</prefix>
- <!-- The search clause just finds ?works, present is done below -->
- <form>SELECT DISTINCT ?work </form>
- <criteria>?work a bf:Work</criteria>
-
- <!-- bf.uri is a simple way to get to a work -->
- <index type="bf.uri"> ?work a bf:Work FILTER( ?work = %u ) </index>
-
- <!-- Title indexes -->
- <!-- These are messy, there are so many ways to get to a title -->
-
- <!-- Main title. Looks logical, but in practice we have seen only a very
- small number of these -->
- <index type="bf.title">
- ?work bf:title %v FILTER(contains(%v, %s))
- </index>
-
- <!-- worktitle seems to be the most common way to store the title of a work -->
- <index type="bf.worktitle">
- ?work bf:workTitle ?wt .
- ?wt bf:titleValue %v FILTER(contains(%v, %s))
- </index>
-
- <!-- Combining the two above, since users are not likely to know how
- a given title has been indexed -->
- <index type="bf.maintitle">
- {
- ?work bf:workTitle ?wt .
- ?wt bf:titleValue %v FILTER(contains(%v, %s))
- } UNION {
- ?work bf:title %v FILTER(contains(%v, %s))
- }
- </index>
-
-
- <!-- the worktitle can also contain a subtitle and a parttitle -->
- <index type="bf.subtitle">?work bf:workTitle ?wt .
- ?wt bf:subtitle %v FILTER(contains(%v, %s))
- </index>
-
- <index type="bf.parttitle">
- ?work bf:workTitle ?wt .
- ?wt bf:partTitle %v FILTER(contains(%v, %s))
- </index>
-
- <!-- work.titlevariation - this could also have sub- and partTitles -->
- <index type="bf.titlevariation">
- ?work bf:titleVariation ?tv .
- ?tv bf:titleValue %v FILTER(contains(%v, %s))
- </index>
-
- <!-- Instance titles -->
- <index type="bf.instancetitle">
- ?inst bf:instanceOf ?work .
- ?inst bf:instanceTitle ?it .
- ?it bf:titleValue %v FILTER(contains(%v, %s))
- </index>
-
- <!-- Combined title index. There are so many ways titles can be expresses
- in Bibframe, this seems to cover most of what we have seen -->
- <index type="bf.anytitle">
- { ?work 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 {
- ?work bf:titleVariation ?tv .
- ?tv bf:titleValue %v FILTER(contains(%v, %s))
- } UNION {
- ?inst bf:instanceOf ?work .
- ?inst bf:instanceTitle ?it .
- ?it bf:titleValue %v FILTER(contains(%v, %s))
- } UNION {
- ?work bf:title %v FILTER(contains(%v, %s))
- }
- </index>
-
- <!-- Author indexes. Much simpler than titles. -->
- <index type="bf.creator">
- ?work bf:creator ?c .
- ?c bf:label %v FILTER(contains(%v, %s))
- </index>
-
- <index type="bf.contributor">
- ?work bf:contributor ?c .
- ?c bf:label %v FILTER(contains(%v, %s))
- </index>
-
- <index type="bf.anyauthor">
- {
- ?work bf:creator ?c .
- ?c bf:label %v FILTER(contains(%v, %s))
- } UNION {
- ?work bf:contributor ?c .
- ?c bf:label %v FILTER(contains(%v, %s))
- }
- </index>
-
- <!-- Subjects -->
- <index type="bf.subject">
- ?work bf:subject ?subject .
- ?subject bf:label %v FILTER(contains(%v, %s))
- </index>
-
- <!-- Indexes for persons, organizations, etc -->
- <!-- The person (etc) may be in any relation to the work, subject,
- creator, etc, as long as there is a direct link -->
- <index type="bf.person">
- ?work ?rel ?person .
- ?person a bf:Person .
- ?person bf:label %v FILTER(contains(%v, %s))
- </index>
- <!-- TODO - make many more like the person above -->
-
- <!-- Present formats -->
- <!-- BF-L is just the links -->
- <present type="BF-L">
- CONSTRUCT { ?work ?rel ?subj }
- WHERE {
- ?work a bf:Work .
- ?work ?rel ?subj .
- ?work ?rel ?subj FILTER( str(?work) = %s )
- }
- </present>
-
- <!-- BF-F expands all links, except to instances and other works -->
- <present type="BF-F">
- CONSTRUCT { ?work ?rel ?obj .
- ?obj ?rel1 ?obj1 .
- ?obj1 ?rel2 ?obj2 .
- ?obj2 ?rel3 ?obj3 }
- WHERE {
- ?work a bf:Work .
- ?work ?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 }
- }
- ?work ?rel ?obj FILTER( str(?work) = %s )
- }
- </present>
-
- <!-- full, with instances. Experimental! -->
- <present type="BF-FI">
- CONSTRUCT { %u ?rel ?wobj1 .
- ?wobj1 ?wrel1 ?wobj2 .
- ?wobj2 ?wrel2 ?wobj3 .
- ?inst ?irel1 ?iobj1 .
- ?iobj1 ?irel2 ?iobj2 .
- ?iobj2 ?irel3 ?iobj3 }
- WHERE {
- %u a bf:Work .
- %u ?rel ?wobj1 .
- OPTIONAL { <!-- note, this is not in the final construct
- the linking triplet will get included like any others -->
- ?inst bf:instanceOf %u
- }
- &workfull; <!-- This does not seem to get expanded!! TODO -->
- 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 }
- }
- <!--&instfull; -->
- OPTIONAL {
- ?inst ?irel1 ?iobj1
- }
- OPTIONAL {
- ?iobj1 ?irel2 ?iobj2
- }
- OPTIONAL {
- ?iobj2 ?irel3 ?iobj3
- }
-
- }
- </present>
- </db>
-
- <!-- Instance database -->
-
- <db path="instance" schema="sparql-results">
- <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
- <prefix>bf: http://bibframe.org/vocab/</prefix>
- <!-- The search clause just finds ?insts, present is done below -->
- <form>SELECT DISTINCT ?inst </form>
- <criteria>?inst a bf:Instance</criteria>
-
- <!-- bf.uri is a simple way to get to a work -->
- <index type="bf.uri"> ?inst a bf:Instance FILTER( ?inst = %u ) </index>
-
- <!-- Title indexes -->
- <!-- These are messy, there are so many ways to get to a title -->
-
- <!-- Main title. Looks logical. Many instances seem to have a title -->
- <index type="bf.title">
- ?inst bf:title %v FILTER(contains(%v, %s))
- </index>
-
- <!-- instancetitle is also pretty common -->
- <index type="bf.instancetitle">
- ?inst bf:instanceTitle ?it .
- ?it bf:titleValue %v FILTER(contains(%v, %s))
- </index>
-
- <index type="bf.titlestatement">
- ?inst bf:titleStatement %v FILTER(contains(%v, %s))
- </index>
-
- <!-- Combining the two above, since users are not likely to know how
- a given title has been indexed -->
- <index type="bf.maintitle">
- {
- ?inst bf:instanceTitle ?it .
- ?it bf:titleValue %v FILTER(contains(%v, %s))
- } UNION {
- ?inst bf:title %v FILTER(contains(%v, %s))
- }
- </index>
-
-
- <!-- the instancetitle can also contain a subtitle and a parttitle -->
- <index type="bf.subtitle">
- ?inst bf:instanceTitle ?it .
- ?it bf:subtitle %v FILTER(contains(%v, %s))
- </index>
-
- <index type="bf.parttitle">
- ?inst bf:instanceTitle ?it .
- ?it bf:partTitle %v FILTER(contains(%v, %s))
- </index>
- <!-- We could also go to the works, and get those titles... -->
-
- <!-- Combining any kind of title into one index -->
- <index type="bf.anytitle">
- {
- ?inst bf:title %v FILTER(contains(%v, %s))
- } UNION {
- ?inst bf:titleStatement %v FILTER(contains(%v, %s))
- } UNION {
- ?inst ?titlerel ?it . <!-- any kind of link -->
- ?it a bf:Title <!-- to something that is a title -->
- {
- ?it bf:titleValue %v FILTER(contains(%v, %s))
+ <filter type="sparql">
+
+ <!-- Which sparql server to use, our demo, or your local installation -->
+ <!--defaults uri="http://bibframe.indexdata.com/sparql/"/-->
+ <defaults uri="http://localhost:8890/sparql/"/>
+
+ <!-- "thing" database that will be included all real databases -->
+ <db path="thing"> <!-- no schema, so it is not directly searchable -->
+ <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
+ <prefix>bf: http://bibframe.org/vocab/</prefix>
+ <form>SELECT DISTINCT ?thing </form>
+
+ <!-- Common indexes -->
+
+ <!-- bf.uri is a simple way to get to a thing -->
+ <index type="bf.uri">
+ ?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 -->
+ <present type="BF-L">
+ CONSTRUCT {
+ %u ?rel ?subj
+ }
+ WHERE {
+ %u ?rel ?subj .
+ }
+ </present>
+
+ </db>
+
+ <!-- "smallindex" db that will be included in work and instance -->
+ <!-- It provides the small indexes like bf.person, bf.place, etc -->
+ <!-- These match a person, etc, no matter what the relation to that -->
+ <!-- is, as long as there is a direct link -->
+ <!-- The %v gets assigned a new variable name, like ?v0. -->
+ <!-- The %vx gets the same ?v0, with the x suffixed to it, by regular -->
+ <!-- This way, we use a different variable for each index clause, and -->
+ <!-- do not get into trouble if we have an AND between two of the same kind -->
+ <db path="smallindex">
+ <index type="bf.personX">
+ ?thing ?rel %vx .
+ %vx a bf:Person .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.topic">
+ ?thing ?rel %vx .
+ %vx a bf:Topic .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.place">
+ ?thing ?rel %vx .
+ %vx a bf:Place .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.agent">
+ ?thing ?rel %vx .
+ %vx a bf:Agent .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.meeting">
+ ?thing ?rel %vx .
+ %vx a bf:Meeting .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.organization">
+ ?thing ?rel %vx .
+ %vx a bf:Organization .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ <index type="bf.event">
+ ?thing ?rel %vx .
+ %vx a bf:Event .
+ %vx bf:label %v FILTER(contains(%v, %s))
+ </index>
+ </db>
+
+ <!-- work database -->
+
+ <db path="work" schema="sparql-results" include="thing smallindex">
+
+ <!-- The search clause just finds ?things, present is done below -->
+ <criteria>?thing a bf:Work</criteria>
+
+ <!-- Title indexes -->
+ <!-- These are messy, there are so many ways to get to a title -->
+
+ <!-- Main title. Looks logical, but in practice we have not seen -->
+ <!-- many of these -->
+ <index type="bf.title">
+ ?thing bf:title %v FILTER(contains(%v, %s))
+ </index>
+
+ <!-- worktitle.titleValue seems to be the most common way to -->
+ <!-- store the title of a work -->
+ <index type="bf.worktitle">
+ ?thing bf:workTitle %v_wt .
+ %v_wt bf:titleValue %v FILTER(contains(%v, %s))
+ </index>
+
+ <!-- Combining the two above, since users are not likely -->
+ <!-- to know how a given title has been indexed -->
+ <!-- TODO is "maintitle" a good name for this? I made it up myself -->
+ <index type="bf.maintitle">
+ {
+ ?thing bf:workTitle %v_wt .
+ %v_wt bf:titleValue %v FILTER(contains(%v, %s))
+ } UNION {
+ ?thing bf:title %v FILTER(contains(%v, %s))
+ }
+ </index>
+
+ <!-- the worktitle can also contain a subtitle and a parttitle -->
+ <index type="bf.subtitle">
+ ?thing bf:workTitle %v_wt .
+ %v_wt bf:subtitle %v FILTER(contains(%v, %s))
+ </index>
+
+ <index type="bf.parttitle">
+ ?thing bf:workTitle %v_wt .
+ %v_wt bf:partTitle %v FILTER(contains(%v, %s))
+ </index>
+
+ <!-- work.titlevariation - this could also have sub- and partTitles -->
+ <index type="bf.titlevariation">
+ ?thing bf:titleVariation %v_tv .
+ %v_tv bf:titleValue %v FILTER(contains(%v, %s))
+ </index>
+
+ <!-- Instance titles -->
+ <index type="bf.instancetitle">
+ %v_inst bf:instanceOf ?thing .
+ %v_inst bf:instanceTitle %v_tit .
+ %v_tit bf:titleValue %v FILTER(contains(%v, %s))
+ </index>
+
+ <!-- Combined title index. There are so many ways titles can be expresses
+ in Bibframe, this seems to cover most of what we have seen -->
+ <index type="bf.anytitle">
+ {
+ ?thing bf:title %v FILTER(contains(%v, %s))
+ } UNION { <!-- any kind of link -->
+ ?thing ?titlerel %v_ti . <!-- mostly workTitle, but others too -->
+ %v_ti a bf:Title <!-- to something that is a title -->
+ {
+ %v_ti bf:titleValue %v FILTER(contains(%v, %s))
+ } UNION {
+ %v_ti bf:partTitle %v FILTER(contains(%v, %s))
+ } UNION {
+ %v_ti bf:subtitle %v FILTER(contains(%v, %s))
+ }