LOC-6: Author indexes
[mp-sparql-moved-to-github.git] / bibframe / triplestore.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE html [
3 <!-- Entity definitions for commonly used idioms -->
4 <!-- TODO - Now it accepts these, but will not expand them in place! -->
5 <!-- Seems we can not use many special characters in these: <> % etc -->
6   <!ENTITY workfull "FOOBAR" >
7   <!ENTITY workfullX "
8           OPTIONAL {
9               ?wobj ?wrel1 ?wobj1
10               MINUS { ?wobj a bf:Work }
11               MINUS { ?wobj a bf:Instance }
12           }
13           OPTIONAL {
14               ?wobj1 ?wrel2 ?wobj2
15               MINUS { ?wobj1 a bf:Work }
16               MINUS { ?wobj1 a bf:Instance }
17           }
18           OPTIONAL {
19               ?wobj2 ?wrel3 ?wobj3
20               MINUS { ?wobj2 a bf:Work }
21               MINUS { ?wobj2 a bf:Instance }
22           }
23   ">
24   <!ENTITY instfull "
25           OPTIONAL {
26             ?inst ?irel1 ?iobj1
27           }
28           OPTIONAL {
29             ?iobj1 ?irel2 ?iobj2
30           }
31           OPTIONAL {
32             ?iobj2 ?irel3 ?iobj3
33           }
34   ">
35 ]>
36
37 <filters  xmlns="http://indexdata.com/metaproxy">
38   <filter type="sparql">
39       <!-- Which sparql server to use, our demo, or your local installation -->
40     <defaults uri="http://bibframe.indexdata.com/sparql/"/>
41     <!--defaults uri="http://localhost:8890/sparql/"/-->
42
43     <!-- Any search in work returns just a list of records.
44          Present will make another request for each record to get the level
45          of details we want, depending on the schema.  -->
46     <db path="work" schema="sparql-results">
47       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
48       <prefix>bf: http://bibframe.org/vocab/</prefix>
49       <form>SELECT DISTINCT ?work </form>
50       <criteria>?work a bf:Work</criteria>
51
52       <!-- bf.uri is a simple way to get to a work -->
53       <index type="bf.uri"> ?work a bf:Work FILTER( ?work  = %u ) </index>
54
55       <!-- Title indexes, directly via work.workTitle -->
56       <index type="bf.title">
57           ?work bf:workTitle ?wt .
58           ?wt bf:titleValue %v FILTER(contains(%v, %s))
59       </index>
60
61       <index type="bf.subtitle">?work bf:workTitle ?wt .
62           ?wt bf:subtitle %v FILTER(contains(%v, %s))
63       </index>
64
65       <index type="bf.parttitle">
66           ?work bf:workTitle ?wt .
67           ?wt bf:partTitle %v FILTER(contains(%v, %s))
68       </index>
69
70       <!-- work.titlevariation - this could also have sub- and partTitles -->
71       <index type="bf.titlevariation">
72           ?work bf:titleVariation ?tv .
73           ?tv bf:titleValue %v FILTER(contains(%v, %s))
74       </index>
75
76       <!-- Instance titles -->
77       <index type="bf.instancetitle">
78           ?inst bf:instanceOf ?work .
79           ?inst bf:instanceTitle ?it .
80           ?it bf:titleValue %v FILTER(contains(%v, %s))
81       </index>
82
83       <!-- Combined title index. There are so many ways titles can be expresses
84       in Bibframe, this seems to cover most of what we have seen -->
85       <index type="bf.anytitle">
86           { ?work bf:workTitle ?wt .
87               { ?wt bf:titleValue %v FILTER(contains(%v, %s)) } UNION
88               { ?wt bf:subtitle %v FILTER(contains(%v, %s)) } UNION
89               { ?wt bf:partTitle %v FILTER(contains(%v, %s)) }
90           } UNION {
91               ?work bf:titleVariation ?tv .
92               ?tv bf:titleValue %v FILTER(contains(%v, %s)) 
93           } UNION {
94               ?inst bf:instanceOf ?work .
95               ?inst bf:instanceTitle ?it .
96               ?it bf:titleValue %v FILTER(contains(%v, %s))
97           }
98       </index>
99
100       <!-- Author indexes -->
101       <index type="bf.creator">
102           ?work bf:creator ?c .
103           ?c bf:label %v FILTER(contains(%v, %s))
104       </index>
105
106       <index type="bf.contributor">
107           ?work bf:contributor ?c .
108           ?c bf:label %v FILTER(contains(%v, %s))
109           </index>
110
111       <!-- Subjects -->
112       <index type="bf.subject">?work bf:subject ?subject .
113           ?subject bf:label %v FILTER(contains(%v, %s))
114       </index>
115
116       <!-- Present formats. BF-L is just the links -->
117       <present type="BF-L">
118         CONSTRUCT { ?work ?rel ?subj }
119          WHERE {
120          ?work a bf:Work .
121          ?work ?rel ?subj .
122          ?work ?rel ?obj FILTER( str(?work) = %s )
123         }
124       </present>
125
126       <!-- BF-F expands all links, except to instances -->
127       <present type="BF-F"> 
128         CONSTRUCT { ?work ?rel ?obj .
129                     ?obj ?rel1 ?obj1 .
130                     ?obj1 ?rel2 ?obj2 .
131                     ?obj2 ?rel3 ?obj3 }
132          WHERE {
133          ?work a bf:Work .
134          ?work ?rel ?obj .
135         OPTIONAL { 
136           ?obj ?rel1 ?obj1  
137             MINUS { ?obj a bf:Work } 
138           }
139         OPTIONAL {
140           ?obj1 ?rel2 ?obj2 
141             MINUS { ?obj1 a bf:Work } 
142           } 
143         OPTIONAL { 
144           ?obj2 ?rel3 ?obj3 
145             MINUS { ?obj2 a bf:Work } 
146           }
147          ?work ?rel ?obj FILTER( str(?work) = %s )
148         }
149       </present>
150
151       <!-- full, with instances. Experimental! -->
152       <present type="BF-FI">  
153         CONSTRUCT { %u ?rel ?wobj1 .
154                     ?wobj1 ?wrel1 ?wobj2 .
155                     ?wobj2 ?wrel2 ?wobj3 .
156                     ?inst ?irel1 ?iobj1 .
157                     ?iobj1 ?irel2 ?iobj2 .
158                     ?iobj2 ?irel3 ?iobj3 }
159          WHERE {
160           %u a bf:Work .
161           %u ?rel ?wobj1 .
162           OPTIONAL { <!-- note, this is not in the final construct
163           the linking triplet will get included like any others -->
164             ?inst bf:instanceOf %u
165           } 
166           &workfull; <!-- This does not seem to get expanded!! TODO -->
167           OPTIONAL {
168               ?wobj ?wrel1 ?wobj1
169               MINUS { ?wobj a bf:Work }
170               MINUS { ?wobj a bf:Instance }
171           }
172           OPTIONAL {
173               ?wobj1 ?wrel2 ?wobj2
174               MINUS { ?wobj1 a bf:Work }
175               MINUS { ?wobj1 a bf:Instance }
176           }
177           OPTIONAL {
178               ?wobj2 ?wrel3 ?wobj3
179               MINUS { ?wobj2 a bf:Work }
180               MINUS { ?wobj2 a bf:Instance }
181           }
182           <!--&instfull; -->
183           OPTIONAL {
184             ?inst ?irel1 ?iobj1
185           }
186           OPTIONAL {
187             ?iobj1 ?irel2 ?iobj2
188           }
189           OPTIONAL {
190             ?iobj2 ?irel3 ?iobj3
191           }
192
193         }
194       </present>
195     </db>
196     <!-- Instance searches, need to be refined later. TODO -->
197     <db path="instance" schema="sparql-results">
198       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
199       <prefix>bf: http://bibframe.org/vocab/</prefix>
200       <form>SELECT ?instance ?title ?format</form>
201       <criteria>?instance a bf:Instance</criteria>
202       <criteria>?instance bf:title ?title</criteria>
203       <index type="4">?instance bf:title %v FILTER(contains(%v, %s))</index>
204       <criteria>?instance bf:format ?format</criteria>
205       <index type="1013">?instance bf:format %s</index>
206     </db>
207
208     <!-- Small databases -->
209    
210     <!-- "small" contains all the things common to all small databases -->
211     <!-- It is only to be used as an include, it is not searchable, since -->
212     <!-- it has no schema atribute -->
213     <!-- It is divided into "smallindex", "smallbody", and a "small" that includes
214     both, so that title searches can include the body, but have different indexes -->
215     
216     <db path="smallindex">
217       <index type="any">?thing bf:label %v FILTER(contains(%v, %s))</index>
218       <index type="1016">?thing bf:label %v FILTER(contains(%v, %s))</index>
219     </db>
220
221     <db path="smallbody">
222       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
223       <prefix>bf: http://bibframe.org/vocab/</prefix>
224       <form>SELECT DISTINCT ?thing </form>
225       <criteria>?thing ?rel ?obj</criteria>
226       <present type="BF-L">
227         CONSTRUCT { %u ?rel ?obj }
228          WHERE {
229            %u ?rel ?obj .
230          }
231       </present>
232       <!-- Experimental, to get just the URIs out, in proper rdf. Probably not useful 
233       <uri type="BF-U">
234         CONSTRUCT { %u bf:uri %u }
235          WHERE {
236            %u bf:label ?lbl .
237          }
238       </uri>
239       -->
240       <present type="BF-F">
241           <!-- I don't think we need more than one level for these simple 
242           databases -->
243         CONSTRUCT { %u ?rel ?obj . 
244                     ?obj ?rel1 ?obj1 .
245                   }
246          WHERE {
247            %u ?rel ?obj .
248            OPTIONAL { ?obj ?rel1 ?obj1 }
249          }
250       </present>
251     </db>
252     <db path="small" include="smallindex smallbody"/>
253     
254     <db path="place" schema="sparql-results" include="small" >
255       <criteria>?thing a bf:Place</criteria>
256       <index type="bf.place">?thing bf:label %v FILTER(contains(%v, %s))</index>
257     </db>
258     <db path="person" schema="sparql-results" include="small" >
259       <criteria>?thing a bf:Person</criteria>
260       <index type="bf.person">?thing bf:label %v FILTER(contains(%v, %s))</index>
261     </db>
262     <db path="meeting" schema="sparql-results" include="small" >
263       <criteria>?thing a bf:Meeting</criteria>
264       <index type="bf.meeting">?thing bf:label %v FILTER(contains(%v, %s))</index>
265     </db>
266     <db path="agent" schema="sparql-results" include="small" >
267       <criteria>?thing a bf:Agent</criteria>
268       <index type="bf.agent">?thing bf:label %v FILTER(contains(%v, %s))</index>
269     </db>
270     <db path="event" schema="sparql-results" include="small" >
271       <criteria>?thing a bf:Event</criteria>
272       <index type="bf.event">?thing bf:label %v FILTER(contains(%v, %s))</index>
273     </db>
274     <db path="organization" schema="sparql-results" include="small" >
275       <criteria>?thing a bf:Organization</criteria>
276       <index type="bf.organization">?thing bf:label %v FILTER(contains(%v, %s))</index>
277     </db>
278     <db path="topic" schema="sparql-results" include="small" >
279       <criteria>?thing a bf:Topic</criteria>
280       <index type="bf.topic">?thing bf:label %v FILTER(contains(%v, %s))</index>
281     </db>
282
283     <!-- Title search, probably not needed. -->
284     <db path="title" schema="sparql-results" include="smallbody" >
285       <criteria>?thing a bf:Title</criteria>
286       <index type="any">
287            { ?thing bf:titleValue %v FILTER(contains(%v, %s)) } UNION
288            { ?thing bf:subtitle %v FILTER(contains(%v, %s)) } UNION
289            { ?thing bf:partTitle %v FILTER(contains(%v, %s)) } 
290       </index>
291       <index type="1016">
292            { ?thing bf:titleValue %v FILTER(contains(%v, %s)) } UNION
293            { ?thing bf:subtitle %v FILTER(contains(%v, %s)) } UNION
294            { ?thing bf:partTitle %v FILTER(contains(%v, %s)) } 
295       </index>
296       <index type="bf.title">?thing bf:titleValue %v FILTER(contains(%v, %s))</index>
297       <index type="bf.subtitle">?thing bf:subtitle %v FILTER(contains(%v, %s))</index>
298       <index type="bf.parttitle">?thing bf:partTitle %v FILTER(contains(%v, %s))</index>
299     </db>
300
301     <!-- A hack to be able to look at any triplet in the base -->
302     <!-- TODO - Switch to the new system, probably using "small" -->
303     <db path="node" schema="sparql-results">
304       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
305       <prefix>bf: http://bibframe.org/vocab/</prefix>
306       <form>SELECT ?node ?rel ?obj</form>
307       <index type="any">?node ?rel ?obj FILTER( str(?node) = %s )</index>
308     </db>
309     <!-- A way to see which triplets refers to a given uri. -->
310     <!-- TODO - Switch to the new system, probably using "small" -->
311     <db path="ref" schema="sparql-results">
312       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
313       <prefix>bf: http://bibframe.org/vocab/</prefix>
314       <form>SELECT ?node ?rel ?obj</form>
315       <index type="any">?node ?rel ?obj FILTER( str(?obj) = %s )</index>
316     </db>
317   </filter>
318   <filter type="log">
319     <message>http</message>
320     <category apdu="true"/>
321   </filter>
322   <filter type="http_client">
323     <x-forwarded-for>true</x-forwarded-for>
324   </filter>
325 </filters>