whitespace
[mp-sparql-moved-to-github.git] / bibframe / triplestore.xml
1 <?xml version="1.0"?>
2
3 <filters  xmlns="http://indexdata.com/metaproxy">
4     <filter type="sparql">
5
6         <!-- Which sparql server to use, our demo, or your local installation -->
7         <!--defaults uri="http://bibframe.indexdata.com/sparql/"/-->
8         <defaults uri="http://localhost:8890/sparql/"/>
9
10         <!-- "thing" database that will be included all real databases -->
11         <db path="thing">  <!-- no schema, so it is not directly searchable -->
12             <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
13             <prefix>bf: http://bibframe.org/vocab/</prefix>
14             <form>SELECT DISTINCT ?thing </form>
15
16             <!-- Common indexes -->
17
18             <!-- bf.uri is a simple way to get to a thing -->
19             <index type="bf.uri">
20                 ?thing  rdf:type ?any FILTER( ?thing  = %u ) </index>
21
22
23             <!-- The BF-L present format is the same for everything -->
24             <!-- Each db is supposed to provide a dedicated BF-F present format -->
25             <present type="BF-L">
26                 CONSTRUCT {
27                     ?thing ?rel ?subj
28                 }
29                 WHERE {
30                     ?thing ?rel ?subj .
31                     ?thing ?rel ?subj FILTER( str(?thing) = %s )
32                 }
33             </present>
34
35         </db>
36
37         <!-- "smallindex" db that will be included in work and instance -->
38         <!-- It provides the small indexes like bf.person, bf.place, etc -->
39         <db path="smallindex">
40             <!-- Indexes for persons, organizations, etc -->
41             <!-- The person (etc) may be in any relation to the thing, -->
42             <!-- subject, creator, etc, as long as there is a direct link -->
43             <index type="bf.person">
44                 ?thing ?rel ?person .
45                 ?person a bf:Person .
46                 ?person bf:label %v FILTER(contains(%v, %s))
47             </index>
48             <!-- TODO - make many more like the person above -->
49         </db>
50
51         <!-- work database -->
52
53         <db path="work" schema="sparql-results" include="thing smallindex">
54
55             <!-- The search clause just finds ?things, present is done below -->
56             <criteria>?thing a bf:Work</criteria>
57
58             <!-- Title indexes -->
59             <!-- These are messy, there are so many ways to get to a title -->
60
61             <!-- Main title. Looks logical, but in practice we have not seen -->
62             <!-- many of these -->
63             <index type="bf.title">
64                     ?thing bf:title %v FILTER(contains(%v, %s))
65             </index>
66
67             <!-- worktitle.titleValue seems to be the most common way to -->
68             <!-- store the title of a work -->
69             <index type="bf.worktitle">
70                 ?thing bf:workTitle ?wt .
71                 ?wt bf:titleValue %v FILTER(contains(%v, %s))
72             </index>
73
74             <!-- Combining the two above, since users are not likely -->
75             <!-- to know how a given title has been indexed -->
76             <!-- TODO is "maintitle" a good name for this? I made it up myself -->
77             <index type="bf.maintitle">
78                 {
79                     ?thing bf:workTitle ?wt .
80                     ?wt bf:titleValue %v FILTER(contains(%v, %s))
81                 } UNION {
82                     ?thing bf:title %v FILTER(contains(%v, %s))
83                 }
84             </index>
85
86             <!-- the worktitle can also contain a subtitle and a parttitle -->
87             <index type="bf.subtitle">?thing bf:workTitle ?wt .
88                 ?wt bf:subtitle %v FILTER(contains(%v, %s))
89             </index>
90
91             <index type="bf.parttitle">
92                 ?thing bf:workTitle ?wt .
93                 ?wt bf:partTitle %v FILTER(contains(%v, %s))
94             </index>
95
96             <!-- work.titlevariation - this could also have sub- and partTitles -->
97             <index type="bf.titlevariation">
98                 ?thing bf:titleVariation ?tv .
99                 ?tv bf:titleValue %v FILTER(contains(%v, %s))
100             </index>
101
102             <!-- Instance titles -->
103             <index type="bf.instancetitle">
104                 ?inst bf:instanceOf ?thing .
105                 ?inst bf:instanceTitle ?it .
106                 ?it bf:titleValue %v FILTER(contains(%v, %s))
107             </index>
108
109             <!-- Combined title index. There are so many ways titles can be expresses
110             in Bibframe, this seems to cover most of what we have seen -->
111             <index type="bf.anytitle">
112                 {
113                     ?thing bf:title %v FILTER(contains(%v, %s))
114                 } UNION { <!-- any kind of link -->
115                     ?thing ?titlerel ?ti . <!-- mostly workTitle, but others too -->
116                     ?ti a bf:Title <!-- to something that is a title -->
117                     {
118                         ?ti bf:titleValue %v FILTER(contains(%v, %s))
119                     } UNION {
120                         ?ti bf:partTitle %v FILTER(contains(%v, %s))
121                     } UNION {
122                         ?ti bf:subtitle %v FILTER(contains(%v, %s))
123                     }
124                 } UNION {
125                     ?inst bf:instanceOf ?thing .
126                     ?inst bf:instanceTitle ?it .
127                     ?it bf:titleValue %v FILTER(contains(%v, %s))
128                 } UNION {
129                 }
130             </index>
131
132             <!-- Author indexes. Much simpler than titles. -->
133             <index type="bf.creator">
134                 ?thing bf:creator ?c .
135                 ?c bf:label %v FILTER(contains(%v, %s))
136             </index>
137
138             <index type="bf.contributor">
139                 ?thing bf:contributor ?c .
140                 ?c bf:label %v FILTER(contains(%v, %s))
141             </index>
142
143             <index type="bf.anyauthor"> <!-- TODO - Is this a good name? -->
144                 {
145                     ?thing bf:creator ?c .
146                     ?c bf:label %v FILTER(contains(%v, %s))
147                 } UNION {
148                     ?thing bf:contributor ?c .
149                     ?c bf:label %v FILTER(contains(%v, %s))
150                 }
151             </index>
152
153             <!-- Subjects -->
154             <!-- Note that these refer to anything with a bf:subject relation -->
155             <!-- The actual item is likely to be something like topic person etc -->
156             <index type="bf.subject">
157                 ?thing bf:subject ?subject .
158                 ?subject bf:label %v FILTER(contains(%v, %s))
159             </index>
160
161
162             <!-- Present formats -->
163             <!-- BF-L comes from the "thing" template -->
164             <!-- BF-F expands all links, even to instances but not other works -->
165             <present type="BF-F">
166                 CONSTRUCT {
167                     %u ?rel ?wobj1 .
168                     ?wobj1 ?wrel1 ?wobj2 .
169                     ?wobj2 ?wrel2 ?wobj3 .
170                     ?inst ?irel1 ?iobj1 .
171                     ?iobj1 ?irel2 ?iobj2 .
172                     ?iobj2 ?irel3 ?iobj3
173                 }
174                 WHERE {
175                     %u a bf:Work .
176                     %u ?rel ?wobj1 .
177
178                     OPTIONAL {
179                         ?wobj1 ?wrel2 ?wobj2
180                             MINUS { ?wobj1 a bf:Work }
181                             MINUS { ?wobj1 a bf:Instance }
182                         OPTIONAL {
183                             ?wobj2 ?wrel3 ?wobj3
184                                 MINUS { ?wobj2 a bf:Work }
185                                 MINUS { ?wobj2 a bf:Instance }
186                         }
187                     }
188                     <!-- Link to the instance(s) -->
189                     OPTIONAL {
190                         ?inst bf:instanceOf %u .
191                         ?inst ?irel1 ?iobj1
192                         OPTIONAL {
193                             ?iobj1 ?irel2 ?iobj2
194                                 MINUS { ?iobj1 a bf:Work }
195                                 MINUS { ?iobj1 a bf:Instance }
196                             OPTIONAL {
197                                 ?iobj2 ?irel3 ?iobj3
198                                     MINUS { ?iobj2 a bf:Work }
199                                     MINUS { ?iobj2 a bf:Instance }
200                             }
201                         }
202                     }
203                 }
204             </present>
205         </db>
206
207         <!-- Instance database -->
208
209         <db path="instance" schema="sparql-results" include="thing smallindex">
210             <criteria>?thing a bf:Instance</criteria>
211
212             <!-- Title indexes -->
213             <!-- These are messy, there are so many ways to get to a title -->
214
215             <!-- Main title. Looks logical. Many instances seem to have a title -->
216             <index type="bf.title">
217                 ?thing bf:title %v FILTER(contains(%v, %s))
218             </index>
219
220             <!-- instancetitle is also pretty common -->
221             <index type="bf.instancetitle">
222                 ?thing bf:instanceTitle ?it .
223                 ?it bf:titleValue %v FILTER(contains(%v, %s))
224             </index>
225
226             <index type="bf.titlestatement">
227                 ?thing bf:titleStatement %v FILTER(contains(%v, %s))
228             </index>
229
230             <!-- Combining the two above, since users are not likely to know how
231             a given title has been indexed -->
232             <index type="bf.maintitle">
233                 {
234                     ?thing bf:instanceTitle ?it .
235                     ?it bf:titleValue %v FILTER(contains(%v, %s))
236                 } UNION {
237                     ?thing bf:title %v FILTER(contains(%v, %s))
238                 }
239             </index>
240
241
242             <!-- the instancetitle can also contain a subtitle and a parttitle -->
243             <index type="bf.subtitle">
244                 ?thing bf:instanceTitle ?it .
245                 ?it bf:subtitle %v FILTER(contains(%v, %s))
246             </index>
247
248             <index type="bf.parttitle">
249                 ?thing bf:instanceTitle ?it .
250                 ?it bf:partTitle %v FILTER(contains(%v, %s))
251             </index>
252             <!-- We could also go to the works, and get those titles... -->
253
254             <!-- Combining any kind of title into one index -->
255             <index type="bf.anytitle">
256                 {
257                     ?thing bf:title %v FILTER(contains(%v, %s))
258                 } UNION {
259                     ?thing bf:titleStatement %v FILTER(contains(%v, %s))
260                 } UNION {
261                     ?thing ?titlerel ?it . <!-- any kind of link -->
262                     ?it a bf:Title <!-- to something that is a title -->
263                     {
264                         ?it bf:titleValue %v FILTER(contains(%v, %s))
265                     } UNION {
266                         ?it bf:partTitle %v FILTER(contains(%v, %s))
267                     } UNION {
268                         ?it bf:subtitle %v FILTER(contains(%v, %s))
269                     }
270                 }
271             </index>
272
273             <!-- Author indexes. Many instances don't have any, works do -->
274             <index type="bf.creator">
275                 ?thing bf:creator ?c .
276                 ?c bf:label %v FILTER(contains(%v, %s))
277             </index>
278
279             <index type="bf.workcreator">
280                 ?thing bf:instanceOf ?work .
281                 ?work bf:creator ?c .
282                 ?c bf:label %v FILTER(contains(%v, %s))
283             </index>
284
285             <index type="bf.workcontributor">
286                 ?thing bf:instanceOf ?work .
287                 ?work bf:contributor ?c .
288                 ?c bf:label %v FILTER(contains(%v, %s))
289             </index>
290
291             <index type="bf.contributor">
292                 ?thing bf:contributor ?c .
293                 ?c bf:label %v FILTER(contains(%v, %s))
294             </index>
295
296             <index type="bf.anyauthor">
297                 {
298                     ?thing bf:creator ?c .
299                     ?c bf:label %v FILTER(contains(%v, %s))
300                 } UNION {
301                     ?thing bf:contributor ?c .
302                     ?c bf:label %v FILTER(contains(%v, %s))
303                 } UNION {
304                     ?thing bf:instanceOf ?work .
305                     ?work bf:creator ?c .
306                     ?c bf:label %v FILTER(contains(%v, %s))
307                 } UNION {
308                     ?thing bf:instanceOf ?work .
309                     ?work bf:contributor ?c .
310                     ?c bf:label %v FILTER(contains(%v, %s))
311                 }
312             </index>
313
314             <!-- Present formats. BF-L comes from "thing" -->
315             <!-- Full instance, with the related work too -->
316             <present type="BF-F">
317                 CONSTRUCT {
318                     %u ?irel1 ?iobj1 .
319                     ?iobj1 ?irel2 ?iobj2 .
320                     ?iobj2 ?irel3 ?iobj3 .
321                     ?work ?wrel1 ?wobj1 .
322                     ?wobj1 ?wrel2 ?wobj2 .
323                     ?wobj2 ?wrel3 ?wobj3
324                 }
325                 WHERE {
326                     %u a bf:Instance .
327                     %u ?irel1 ?iobj1
328                     OPTIONAL {
329                         ?iobj1 ?irel2 ?iobj2
330                             MINUS { ?iobj2 a bf:Work }
331                             MINUS { ?iobj2 a bf:Instance }
332                         OPTIONAL {
333                             ?iobj2 ?irel3 ?iobj3
334                                 MINUS { ?iobj3 a bf:Work }
335                                 MINUS { ?iobj3 a bf:Instance }
336                         }
337                     }
338                     OPTIONAL { <!-- Work -->
339                         %u bf:instanceOf ?work
340                         ?work ?wrel1 ?wobj1
341                         OPTIONAL {
342                             ?wobj1 ?wrel2 ?wobj2
343                                 MINUS { ?wobj1 a bf:Work }
344                                 MINUS { ?wobj1 a bf:Instance }
345                             OPTIONAL {
346                                 ?wobj2 ?wrel3 ?wobj3
347                                     MINUS { ?wobj2 a bf:Work }
348                                     MINUS { ?wobj2 a bf:Instance }
349                             }
350                         }
351                     }
352                 }
353             </present>
354
355         </db>
356
357         <!-- Small databases -->
358
359         <!-- "small" contains all the things common to all small databases -->
360         <!-- It is only to be used as an include, it is not searchable, since -->
361         <!-- it has no schema atribute -->
362         <!-- It is divided into "smallbody", and a "small" that includes -->
363         <!-- the general indexes, so that title searches can include the body, -->
364         <!-- but have different "any" indexes -->
365
366         <db path="smallbody" include="thing">
367             <present type="BF-F">
368                 <!-- I don't think we need more than one level -->
369                 <!--for these simple databases -->
370                 CONSTRUCT {
371                     %u ?rel ?obj .
372                     ?obj ?rel1 ?obj1 .
373                 }
374                 WHERE {
375                     %u ?rel ?obj .
376                     OPTIONAL { ?obj ?rel1 ?obj1 }
377                 }
378             </present>
379         </db>
380
381         <!-- The combined "small" database defaults -->
382         <db path="small" include="smallbody">
383             <index type="any">
384                 ?thing bf:label %v FILTER(contains(%v, %s))
385             </index>
386             <index type="1016">
387                 ?thing bf:label %v FILTER(contains(%v, %s))
388             </index>
389         </db>
390
391         <!-- Various "small" databases, leaning heavily on the defaults above -->
392         <db path="place" schema="sparql-results" include="small" >
393             <criteria>?thing a bf:Place</criteria>
394             <index type="bf.place">
395                 ?thing bf:label %v FILTER(contains(%v, %s))
396             </index>
397         </db>
398
399         <db path="person" schema="sparql-results" include="small" >
400             <criteria>?thing a bf:Person</criteria>
401             <index type="bf.person">
402                 ?thing bf:label %v FILTER(contains(%v, %s))
403             </index>
404         </db>
405
406         <db path="meeting" schema="sparql-results" include="small" >
407             <criteria>?thing a bf:Meeting</criteria>
408             <index type="bf.meeting">
409                 ?thing bf:label %v FILTER(contains(%v, %s))
410             </index>
411         </db>
412
413         <db path="agent" schema="sparql-results" include="small" >
414             <criteria>?thing a bf:Agent</criteria>
415             <index type="bf.agent">
416                 ?thing bf:label %v FILTER(contains(%v, %s))
417             </index>
418         </db>
419
420         <db path="event" schema="sparql-results" include="small" >
421             <criteria>?thing a bf:Event</criteria>
422             <index type="bf.event">
423                 ?thing bf:label %v FILTER(contains(%v, %s))
424             </index>
425         </db>
426
427         <db path="organization" schema="sparql-results" include="small" >
428             <criteria>?thing a bf:Organization</criteria>
429             <index type="bf.organization">
430                 ?thing bf:label %v FILTER(contains(%v, %s))
431             </index>
432         </db>
433
434         <db path="topic" schema="sparql-results" include="small" >
435             <criteria>?thing a bf:Topic</criteria>
436             <index type="bf.topic">
437                 ?thing bf:label %v FILTER(contains(%v, %s))
438             </index>
439         </db>
440
441         <!-- Title search, for seatching Title objects. -->
442         <!-- Not sure if this is needed, but it is a nice example -->
443         <db path="title" schema="sparql-results" include="smallbody" >
444             <criteria>?thing a bf:Title</criteria>
445
446             <index type="any">
447                 {
448                     ?thing bf:titleValue %v FILTER(contains(%v, %s))
449                 } UNION {
450                     ?thing bf:subtitle %v FILTER(contains(%v, %s))
451                 } UNION {
452                     ?thing bf:partTitle %v FILTER(contains(%v, %s))
453                 }
454             </index>
455
456             <index type="1016">
457                 {
458                     ?thing bf:titleValue %v FILTER(contains(%v, %s))
459                 } UNION {
460                     ?thing bf:subtitle %v FILTER(contains(%v, %s))
461                 } UNION {
462                     ?thing bf:partTitle %v FILTER(contains(%v, %s))
463                 }
464             </index>
465
466             <index type="bf.title">
467                 ?thing bf:titleValue %v FILTER(contains(%v, %s))
468             </index>
469
470             <index type="bf.subtitle">
471                 ?thing bf:subtitle %v FILTER(contains(%v, %s))
472             </index>
473
474             <index type="bf.parttitle">
475                 ?thing bf:partTitle %v FILTER(contains(%v, %s))
476             </index>
477         </db>
478
479         <!-- A hack to be able to look at any triplet in the base -->
480         <!-- TODO - Switch to the new system, probably using "small" -->
481         <db path="node" schema="sparql-results">
482             <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
483             <prefix>bf: http://bibframe.org/vocab/</prefix>
484             <form>SELECT ?node ?rel ?obj</form>
485             <index type="any">?node ?rel ?obj FILTER( str(?node) = %s )</index>
486         </db>
487         <!-- A way to see which triplets refers to a given uri. -->
488         <!-- TODO - Switch to the new system, probably using "small" -->
489         <db path="ref" schema="sparql-results">
490             <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
491             <prefix>bf: http://bibframe.org/vocab/</prefix>
492             <form>SELECT ?node ?rel ?obj</form>
493             <index type="any">?node ?rel ?obj FILTER( str(?obj) = %s )</index>
494         </db>
495     </filter>
496
497     <filter type="log">
498         <message>http</message>
499         <category apdu="true"/>
500     </filter>
501
502     <filter type="http_client">
503         <x-forwarded-for>true</x-forwarded-for>
504     </filter>
505 </filters>