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