Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/mp-sparql
[mp-sparql-moved-to-github.git] / bibframe / triplestore.xml
1 <filters  xmlns="http://indexdata.com/metaproxy">
2   <filter type="sparql">
3       <!-- Which sparql server to use, our demo, or your local installation -->
4     <!--defaults uri="http://bibframe.indexdata.com/sparql/"/-->
5     <defaults uri="http://localhost:8890/sparql/"/>
6
7     <!-- New structure: Any search in work returns just a list of records.
8          Present will make another request to the backend to get the fields
9          we want, depending on the schema. That part is not yet implemented -->
10     <db path="work" schema="sparql-results">
11       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
12       <prefix>bf: http://bibframe.org/vocab/</prefix>
13       <form>SELECT DISTINCT ?work
14       </form>
15       <criteria>?work a bf:Work</criteria>
16       <!-- TODO: Many more indexes like the ones below-->
17       <index type="bf.title">?work bf:workTitle ?wt .
18           ?wt bf:titleValue %v FILTER(contains(%v, %s))</index>
19       <index type="bf.creator">?work bf:creator ?c .
20           ?c bf:label %v FILTER(contains(%v, %s))</index>
21       <index type="bf.subject">?work bf:subject ?subject .
22           ?subject bf:label %v FILTER(contains(%v, %s))
23       </index>
24       <uri type="BF-L">
25         CONSTRUCT { ?work ?rel ?subj }
26         WHERE {
27          ?work a bf:Work .
28          ?work ?rel ?subj .
29          ?work ?rel ?obj FILTER( str(?work) = %s )
30         }
31       </uri>
32       <!-- TODO: Define a query to return detailed information for each
33       schema. For example
34       <present shema="BF-L" results="sparql-results" >
35         <query>
36           SELECT ?sub ?rel ?obj
37           WHERE ?work ?rel ?obj FILTER( str(?work) = %s )
38         </query>
39            - or possibly "FILTER ( ?work = <%u> )" if we define %u to
40            expand to the unquoted URI of the work.
41            - Even better, with %u we can say something like
42               SELECT %u ?rel ?obj
43       </present>
44       -->
45     </db>
46
47     <!-- Experiments while waiting for the present queries to be implemented -->
48     <db path="onework-l" schema="sparql-results">
49       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
50       <prefix>bf: http://bibframe.org/vocab/</prefix>
51       <form>SELECT ?work ?rel ?subj
52       </form>
53       <criteria>?work a bf:Work</criteria>
54       <criteria>?work ?rel ?obj</criteria>
55       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
56     </db>
57     <!-- Returns a decent-looking rdf (except that mp says 0 hits) 
58     with no links expanded -->
59     <db path="onework-l-rdf" schema="rdf">
60       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
61       <prefix>bf: http://bibframe.org/vocab/</prefix>
62       <form>CONSTRUCT { ?work ?rel ?obj }
63       </form>
64       <criteria>?work a bf:Work</criteria>
65       <criteria>?work ?rel ?obj</criteria>
66       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
67     </db>
68     <!-- Expand some links -->
69     <db path="onework-e-rdf" schema="rdf">
70       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
71       <prefix>bf: http://bibframe.org/vocab/</prefix>
72       <form>CONSTRUCT { ?work ?rel ?obj.
73                         ?creator ?crRel ?crObj .
74                         ?subj ?subRel ?subObj }
75       </form>
76       <criteria>?work a bf:Work</criteria>
77       <criteria>?work ?rel ?obj</criteria>
78       <criteria>OPTIONAL { ?work bf:creator ?creator . 
79                            ?creator ?crRel ?crObj }
80       </criteria>
81       <criteria>OPTIONAL { ?work bf:subject ?subj . 
82                            ?subj ?subRel ?subObj }
83       </criteria>
84       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
85     </db>
86     <!-- Expand all things a couple of levels. 
87       In all the data I have seen, two levels is enough. So we do three
88       Lnks to Works and Instances are explicitly excluded from this expansion,
89       and need to be handled separately. This is to avoid looping.
90     -->
91     
92     <db path="onework-f-rdf" schema="rdf">
93       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
94       <prefix>bf: http://bibframe.org/vocab/</prefix>
95       <form>CONSTRUCT { ?work ?rel ?obj .
96                         ?obj ?rel1 ?obj1 .
97                         ?obj1 ?rel2 ?obj2 .
98                         ?obj2 ?rel3 ?obj3
99                         }
100       </form>
101       <criteria>?work a bf:Work</criteria>
102       
103       <criteria>?work ?rel ?obj </criteria>
104       <criteria>OPTIONAL { 
105           ?obj ?rel1 ?obj1  
106             MINUS { ?obj a bf:Work } 
107           } </criteria>
108       <criteria>OPTIONAL {
109           ?obj1 ?rel2 ?obj2 
110             MINUS { ?obj1 a bf:Work } 
111           } </criteria>
112       <criteria>OPTIONAL { 
113           ?obj2 ?rel3 ?obj3 
114             MINUS { ?obj2 a bf:Work } 
115           } </criteria>
116       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
117     </db>
118     <!-- Describe a work. Results may vary between back ends -->
119     <!-- On virtuoso, seems to return the same as onework-l-rdf above -->
120     <db path="onework-d-rdf" schema="rdf">
121       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
122       <prefix>bf: http://bibframe.org/vocab/</prefix>
123       <form>DESCRIBE ?work 
124       </form>
125       <criteria>?work a bf:Work</criteria>
126       <criteria>?work ?rel ?obj</criteria>
127       <criteria>OPTIONAL { ?work bf:creator ?creator . 
128                            ?creator ?crRel ?crObj }
129       </criteria>
130       <criteria>OPTIONAL { ?work bf:subject ?subj . 
131                            ?subj ?subRel ?subObj }
132       </criteria>
133       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
134     </db>
135
136     <!-- This is the old "work" db that will not scale. May be removed -->
137     <db path="concatwork" schema="sparql-results">
138       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
139       <prefix>bf: http://bibframe.org/vocab/</prefix>
140       <form>SELECT
141               ?work
142               (sql:GROUP_DIGEST (?wtitle, ' ; ', 1000, 1)) AS ?title
143               (sql:GROUP_DIGEST (?creatorlabel, ' ; ', 1000, 1))AS ?creator
144               (sql:GROUP_DIGEST (?subjectlabel, ' ; ', 1000, 1))AS ?subject
145       </form>
146       <criteria>?work a bf:Work</criteria>
147
148       <criteria> OPTIONAL {
149           ?work bf:workTitle ?wt .
150           ?wt bf:titleValue ?wtitle }
151       </criteria>
152       <criteria> OPTIONAL {
153           ?work bf:creator ?creator .
154           ?creator bf:label ?creatorlabel }
155       </criteria>
156       <criteria>OPTIONAL {
157           ?work bf:subject ?subject .
158           ?subject bf:label ?subjectlabel }
159       </criteria>
160       <index type="4">?wt bf:titleValue %v FILTER(contains(%v, %s))</index>
161       <index type="1003">?creator bf:label %v FILTER(contains(%v, %s))</index>
162       <index type="21">?subject bf:label %v FILTER(contains(%v, %s))</index>
163       <index type="1016"> {
164             ?work ?op1 ?child .
165             ?child ?op2 %v FILTER(contains(STR(%v), %s))
166           }
167       </index>
168       <modifier>GROUP BY $work</modifier>
169     </db>
170
171     <db path="works" schema="rdf">  <!-- May be removed, will not scale -->
172       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
173       <prefix>bf: http://bibframe.org/vocab/</prefix>
174       <form>CONSTRUCT { 
175           ?work bf:title ?wtitle . 
176           ?work bf:instanceTitle ?title .
177           ?work bf:author ?creator . 
178           ?work bf:subject ?subjectlabel }
179       </form>
180       <criteria>?work a bf:Work</criteria>
181
182       <criteria>?work bf:workTitle ?wt</criteria>
183       <criteria>?wt bf:titleValue ?wtitle</criteria>
184       <index type="4">?wt bf:titleValue %v FILTER(contains(%v, %s))</index>
185       <criteria>?work bf:creator ?creator</criteria>
186       <criteria>?creator bf:label ?creatorlabel</criteria>
187       <index type="1003">?creator bf:label %v FILTER(contains(%v, %s))</index>
188       <criteria>?work bf:subject ?subject</criteria>
189       <criteria>?subject bf:label ?subjectlabel</criteria>
190       <index type="21">?subject bf:label %v FILTER(contains(%v, %s))</index>
191     </db>
192
193     <!-- Instance searches, need to be refined later -->
194     <db path="instance" schema="sparql-results">
195       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
196       <prefix>bf: http://bibframe.org/vocab/</prefix>
197       <form>SELECT ?instance ?title ?format</form>
198       <criteria>?instance a bf:Instance</criteria>
199
200       <criteria>?instance bf:title ?title</criteria>
201       <index type="4">?instance bf:title %v FILTER(contains(%v, %s))</index>
202       <criteria>?instance bf:format ?format</criteria>
203       <index type="1013">?instance bf:format %s</index>
204     </db>
205
206     <!-- Simple databases -->
207     <db path="place" schema="sparql-results">
208       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
209       <prefix>bf: http://bibframe.org/vocab/</prefix>
210       <form>SELECT DISTINCT  ?label ?id ?place ?relatedTo ?authorizedAccessPoint </form>
211       <criteria>?place a bf:Place</criteria>
212       <criteria>?place bf:label ?label</criteria>
213       <criteria>OPTIONAL { ?place bf:identifier ?id}</criteria>
214       <criteria>OPTIONAL { ?place bf:relatedTo ?relatedTo}</criteria>
215       <criteria>OPTIONAL { ?place bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
216       <index type="bf.place">?place bf:label %v FILTER(contains(%v, %s))</index>
217       <index type="any">?place bf:label %v FILTER(contains(%v, %s))</index>
218     </db>
219     <db path="person" schema="sparql-results">
220       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
221       <prefix>bf: http://bibframe.org/vocab/</prefix>
222       <form>SELECT DISTINCT  ?label ?id ?person ?relatedTo ?authorizedAccessPoint </form>
223       <criteria>?person a bf:Person</criteria>
224       <criteria>?person bf:label ?label</criteria>
225       <criteria>OPTIONAL { ?person bf:identifier ?id}</criteria>
226       <criteria>OPTIONAL { ?person bf:relatedTo ?relatedTo}</criteria>
227       <criteria>OPTIONAL { ?person bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
228       <index type="bf.person">?person bf:label %v FILTER(contains(%v, %s))</index>
229       <index type="any">?person bf:label %v FILTER(contains(%v, %s))</index>
230     </db>
231     <db path="meeting" schema="sparql-results">
232       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
233       <prefix>bf: http://bibframe.org/vocab/</prefix>
234       <form>SELECT DISTINCT  ?label ?id ?meeting ?relatedTo ?authorizedAccessPoint </form>
235       <criteria>?meeting a bf:Meeting</criteria>
236       <criteria>?meeting bf:label ?label</criteria>
237       <criteria>OPTIONAL { ?meeting bf:identifier ?id}</criteria>
238       <criteria>OPTIONAL { ?meeting bf:relatedTo ?relatedTo}</criteria>
239       <criteria>OPTIONAL { ?meeting bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
240       <index type="bf.meeting">?meeting bf:label %v FILTER(contains(%v, %s))</index>
241       <index type="any">?meeting bf:label %v FILTER(contains(%v, %s))</index>
242     </db>
243     <db path="agent" schema="sparql-results">
244       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
245       <prefix>bf: http://bibframe.org/vocab/</prefix>
246       <form>SELECT DISTINCT  ?label ?id ?agent ?relatedTo ?authorizedAccessPoint </form>
247       <criteria>?agent a bf:Agent</criteria>
248       <criteria>?agent bf:label ?label</criteria>
249       <criteria>OPTIONAL { ?agent bf:identifier ?id}</criteria>
250       <criteria>OPTIONAL { ?agent bf:relatedTo ?relatedTo}</criteria>
251       <criteria>OPTIONAL { ?agent bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
252       <index type="bf.agent">?agent bf:label %v FILTER(contains(%v, %s))</index>
253       <index type="any">?agent bf:label %v FILTER(contains(%v, %s))</index>
254     </db>
255     <db path="event" schema="sparql-results">
256       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
257       <prefix>bf: http://bibframe.org/vocab/</prefix>
258       <form>SELECT DISTINCT  ?label ?id ?event ?relatedTo ?authorizedAccessPoint </form>
259       <criteria>?event a bf:Event</criteria>
260       <criteria>?event bf:label ?label</criteria>
261       <criteria>OPTIONAL { ?event bf:identifier ?id}</criteria>
262       <criteria>OPTIONAL { ?event bf:relatedTo ?relatedTo}</criteria>
263       <criteria>OPTIONAL { ?event bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
264       <index type="bf.event">?event bf:label %v FILTER(contains(%v, %s))</index>
265       <index type="any">?event bf:label %v FILTER(contains(%v, %s))</index>
266     </db>
267     <db path="organization" schema="sparql-results">
268       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
269       <prefix>bf: http://bibframe.org/vocab/</prefix>
270       <form>SELECT DISTINCT  ?label ?id ?organization ?relatedTo ?authorizedAccessPoint </form>
271       <criteria>?organization a bf:Organization</criteria>
272       <criteria>?organization bf:label ?label</criteria>
273       <criteria>OPTIONAL { ?organization bf:identifier ?id}</criteria>
274       <criteria>OPTIONAL { ?organization bf:relatedTo ?relatedTo}</criteria>
275       <criteria>OPTIONAL { ?organization bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
276       <index type="bf.organization">?organization bf:label %v FILTER(contains(%v, %s))</index>
277       <index type="any">?organization bf:label %v FILTER(contains(%v, %s))</index>
278     </db>
279     <db path="topic" schema="sparql-results">
280       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
281       <prefix>bf: http://bibframe.org/vocab/</prefix>
282       <form>SELECT DISTINCT  ?label ?id ?topic ?relatedTo ?authorizedAccessPoint </form>
283       <criteria>?topic a bf:Topic</criteria>
284       <criteria>?topic bf:label ?label</criteria>
285       <criteria>OPTIONAL { ?topic bf:identifier ?id}</criteria>
286       <criteria>OPTIONAL { ?topic bf:relatedTo ?relatedTo}</criteria>
287       <criteria>OPTIONAL { ?topic bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
288       <index type="bf.topic">?topic bf:label %v FILTER(contains(%v, %s))</index>
289       <index type="any">?topic bf:label %v FILTER(contains(%v, %s))</index>
290     </db>
291
292     <!-- Title search, probably not needed. Will need to be rewritten to the same
293     system as the work search above, with separate present query -->
294     <db path="title" schema="sparql-results">
295         <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
296         <prefix>bf: http://bibframe.org/vocab/</prefix>
297         <form>SELECT DISTINCT ?title ?titleValue 
298             ?formDesignation ?partNumber ?partTitle ?subtitle 
299             ?titleAttribute ?titleQualifier ?titleSource 
300             ?titleType ?titleVariationDate</form>
301         <criteria>?title a bf:Title</criteria>
302         <criteria>OPTIONAL { ?title bf:titleValue ?titleValue}</criteria>
303         <criteria>OPTIONAL { ?title bf:formDesignation ?formDesignation}</criteria>
304         <criteria>OPTIONAL { ?title bf:partNumber ?partNumber}</criteria>
305         <criteria>OPTIONAL { ?title bf:partTitle ?partTitle}</criteria>
306         <criteria>OPTIONAL { ?title bf:subtitle ?subtitle}</criteria>
307         <criteria>OPTIONAL { ?title bf:titleAttribute ?titleAttribute}</criteria>
308         <criteria>OPTIONAL { ?title bf:titleQualifier ?titleQualifier}</criteria>
309         <criteria>OPTIONAL { ?title bf:titleSource ?titleSource}</criteria>
310         <criteria>OPTIONAL { ?title bf:titleType ?titleType}</criteria>
311         <criteria>OPTIONAL { ?title bf:titleVariationDate ?titleVariationDate}</criteria>
312         <index type="bf.title">?title bf:titleValue %v FILTER(contains(%v, %s))</index>
313         <index type="bf.subtitle">?title bf:subtitle %v FILTER(contains(%v, %s))</index>
314         <index type="bf.parttitle">?title bf:partTitle %v FILTER(contains(%v, %s))</index>
315         <index type="any">?title ?rel  %v FILTER(contains(str(%v), %s))</index>
316     </db>
317     <!-- A hack to be able to look at any triplet in the base -->
318     <db path="node" schema="sparql-results">
319       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
320       <prefix>bf: http://bibframe.org/vocab/</prefix>
321       <form>SELECT ?node ?rel ?obj</form>
322       <index type="any">?node ?rel ?obj FILTER( str(?node) = %s )</index>
323     </db>
324     <!-- A way to see which triplets refers to a given uri. -->
325     <db path="ref" schema="sparql-results">
326       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
327       <prefix>bf: http://bibframe.org/vocab/</prefix>
328       <form>SELECT ?node ?rel ?obj</form>
329       <index type="any">?node ?rel ?obj FILTER( str(?obj) = %s )</index>
330     </db>
331   </filter>
332   <filter type="log">
333     <message>http</message>
334     <category apdu="true"/>
335   </filter>
336   <filter type="http_client">
337     <x-forwarded-for>true</x-forwarded-for>
338   </filter>
339 </filters>