Working sub query (uri.schema) MPSPARQL-13
[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     <db path="onework-l-rdf" schema="rdf">
58       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
59       <prefix>bf: http://bibframe.org/vocab/</prefix>
60       <form>CONSTRUCT { ?work ?rel ?subj }
61       </form>
62       <criteria>?work a bf:Work</criteria>
63       <criteria>?work ?rel ?subj</criteria>
64       <index type="any">?work ?rel ?obj FILTER( str(?work) = %s )</index>
65     </db>
66
67     <!-- This is the old "work" db that will not scale. May be removed -->
68     <db path="concatwork" schema="sparql-results">
69       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
70       <prefix>bf: http://bibframe.org/vocab/</prefix>
71       <form>SELECT
72               ?work
73               (sql:GROUP_DIGEST (?wtitle, ' ; ', 1000, 1)) AS ?title
74               (sql:GROUP_DIGEST (?creatorlabel, ' ; ', 1000, 1))AS ?creator
75               (sql:GROUP_DIGEST (?subjectlabel, ' ; ', 1000, 1))AS ?subject
76       </form>
77       <criteria>?work a bf:Work</criteria>
78
79       <criteria> OPTIONAL {
80           ?work bf:workTitle ?wt .
81           ?wt bf:titleValue ?wtitle }
82       </criteria>
83       <criteria> OPTIONAL {
84           ?work bf:creator ?creator .
85           ?creator bf:label ?creatorlabel }
86       </criteria>
87       <criteria>OPTIONAL {
88           ?work bf:subject ?subject .
89           ?subject bf:label ?subjectlabel }
90       </criteria>
91       <index type="4">?wt bf:titleValue %v FILTER(contains(%v, %s))</index>
92       <index type="1003">?creator bf:label %v FILTER(contains(%v, %s))</index>
93       <index type="21">?subject bf:label %v FILTER(contains(%v, %s))</index>
94       <index type="1016"> {
95             ?work ?op1 ?child .
96             ?child ?op2 %v FILTER(contains(STR(%v), %s))
97           }
98       </index>
99       <modifier>GROUP BY $work</modifier>
100     </db>
101
102     <db path="works" schema="rdf">  <!-- May be removed, will not scale -->
103       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
104       <prefix>bf: http://bibframe.org/vocab/</prefix>
105       <form>CONSTRUCT { 
106           ?work bf:title ?wtitle . 
107           ?work bf:instanceTitle ?title .
108           ?work bf:author ?creator . 
109           ?work bf:subject ?subjectlabel }
110       </form>
111       <criteria>?work a bf:Work</criteria>
112
113       <criteria>?work bf:workTitle ?wt</criteria>
114       <criteria>?wt bf:titleValue ?wtitle</criteria>
115       <index type="4">?wt bf:titleValue %v FILTER(contains(%v, %s))</index>
116       <criteria>?work bf:creator ?creator</criteria>
117       <criteria>?creator bf:label ?creatorlabel</criteria>
118       <index type="1003">?creator bf:label %v FILTER(contains(%v, %s))</index>
119       <criteria>?work bf:subject ?subject</criteria>
120       <criteria>?subject bf:label ?subjectlabel</criteria>
121       <index type="21">?subject bf:label %v FILTER(contains(%v, %s))</index>
122     </db>
123
124     <!-- Instance searches, need to be refined later -->
125     <db path="instance" schema="sparql-results">
126       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
127       <prefix>bf: http://bibframe.org/vocab/</prefix>
128       <form>SELECT ?instance ?title ?format</form>
129       <criteria>?instance a bf:Instance</criteria>
130
131       <criteria>?instance bf:title ?title</criteria>
132       <index type="4">?instance bf:title %v FILTER(contains(%v, %s))</index>
133       <criteria>?instance bf:format ?format</criteria>
134       <index type="1013">?instance bf:format %s</index>
135     </db>
136
137     <!-- Simple databases -->
138     <db path="place" schema="sparql-results">
139       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
140       <prefix>bf: http://bibframe.org/vocab/</prefix>
141       <form>SELECT DISTINCT  ?label ?id ?place ?relatedTo ?authorizedAccessPoint </form>
142       <criteria>?place a bf:Place</criteria>
143       <criteria>?place bf:label ?label</criteria>
144       <criteria>OPTIONAL { ?place bf:identifier ?id}</criteria>
145       <criteria>OPTIONAL { ?place bf:relatedTo ?relatedTo}</criteria>
146       <criteria>OPTIONAL { ?place bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
147       <index type="bf.place">?place bf:label %v FILTER(contains(%v, %s))</index>
148       <index type="any">?place bf:label %v FILTER(contains(%v, %s))</index>
149     </db>
150     <db path="person" schema="sparql-results">
151       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
152       <prefix>bf: http://bibframe.org/vocab/</prefix>
153       <form>SELECT DISTINCT  ?label ?id ?person ?relatedTo ?authorizedAccessPoint </form>
154       <criteria>?person a bf:Person</criteria>
155       <criteria>?person bf:label ?label</criteria>
156       <criteria>OPTIONAL { ?person bf:identifier ?id}</criteria>
157       <criteria>OPTIONAL { ?person bf:relatedTo ?relatedTo}</criteria>
158       <criteria>OPTIONAL { ?person bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
159       <index type="bf.person">?person bf:label %v FILTER(contains(%v, %s))</index>
160       <index type="any">?person bf:label %v FILTER(contains(%v, %s))</index>
161     </db>
162     <db path="meeting" schema="sparql-results">
163       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
164       <prefix>bf: http://bibframe.org/vocab/</prefix>
165       <form>SELECT DISTINCT  ?label ?id ?meeting ?relatedTo ?authorizedAccessPoint </form>
166       <criteria>?meeting a bf:Meeting</criteria>
167       <criteria>?meeting bf:label ?label</criteria>
168       <criteria>OPTIONAL { ?meeting bf:identifier ?id}</criteria>
169       <criteria>OPTIONAL { ?meeting bf:relatedTo ?relatedTo}</criteria>
170       <criteria>OPTIONAL { ?meeting bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
171       <index type="bf.meeting">?meeting bf:label %v FILTER(contains(%v, %s))</index>
172       <index type="any">?meeting bf:label %v FILTER(contains(%v, %s))</index>
173     </db>
174     <db path="agent" schema="sparql-results">
175       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
176       <prefix>bf: http://bibframe.org/vocab/</prefix>
177       <form>SELECT DISTINCT  ?label ?id ?agent ?relatedTo ?authorizedAccessPoint </form>
178       <criteria>?agent a bf:Agent</criteria>
179       <criteria>?agent bf:label ?label</criteria>
180       <criteria>OPTIONAL { ?agent bf:identifier ?id}</criteria>
181       <criteria>OPTIONAL { ?agent bf:relatedTo ?relatedTo}</criteria>
182       <criteria>OPTIONAL { ?agent bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
183       <index type="bf.agent">?agent bf:label %v FILTER(contains(%v, %s))</index>
184       <index type="any">?agent bf:label %v FILTER(contains(%v, %s))</index>
185     </db>
186     <db path="event" schema="sparql-results">
187       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
188       <prefix>bf: http://bibframe.org/vocab/</prefix>
189       <form>SELECT DISTINCT  ?label ?id ?event ?relatedTo ?authorizedAccessPoint </form>
190       <criteria>?event a bf:Event</criteria>
191       <criteria>?event bf:label ?label</criteria>
192       <criteria>OPTIONAL { ?event bf:identifier ?id}</criteria>
193       <criteria>OPTIONAL { ?event bf:relatedTo ?relatedTo}</criteria>
194       <criteria>OPTIONAL { ?event bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
195       <index type="bf.event">?event bf:label %v FILTER(contains(%v, %s))</index>
196       <index type="any">?event bf:label %v FILTER(contains(%v, %s))</index>
197     </db>
198     <db path="organization" 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 ?organization ?relatedTo ?authorizedAccessPoint </form>
202       <criteria>?organization a bf:Organization</criteria>
203       <criteria>?organization bf:label ?label</criteria>
204       <criteria>OPTIONAL { ?organization bf:identifier ?id}</criteria>
205       <criteria>OPTIONAL { ?organization bf:relatedTo ?relatedTo}</criteria>
206       <criteria>OPTIONAL { ?organization bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
207       <index type="bf.organization">?organization bf:label %v FILTER(contains(%v, %s))</index>
208       <index type="any">?organization bf:label %v FILTER(contains(%v, %s))</index>
209     </db>
210     <db path="topic" 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 ?topic ?relatedTo ?authorizedAccessPoint </form>
214       <criteria>?topic a bf:Topic</criteria>
215       <criteria>?topic bf:label ?label</criteria>
216       <criteria>OPTIONAL { ?topic bf:identifier ?id}</criteria>
217       <criteria>OPTIONAL { ?topic bf:relatedTo ?relatedTo}</criteria>
218       <criteria>OPTIONAL { ?topic bf:authorizedAccessPoint ?authorizedAccessPoint}</criteria>
219       <index type="bf.topic">?topic bf:label %v FILTER(contains(%v, %s))</index>
220       <index type="any">?topic bf:label %v FILTER(contains(%v, %s))</index>
221     </db>
222
223     <!-- Title search, probably not needed. Will need to be rewritten to the same
224     system as the work search above, with separate present query -->
225     <db path="title" schema="sparql-results">
226         <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
227         <prefix>bf: http://bibframe.org/vocab/</prefix>
228         <form>SELECT DISTINCT ?title ?titleValue 
229             ?formDesignation ?partNumber ?partTitle ?subtitle 
230             ?titleAttribute ?titleQualifier ?titleSource 
231             ?titleType ?titleVariationDate</form>
232         <criteria>?title a bf:Title</criteria>
233         <criteria>OPTIONAL { ?title bf:titleValue ?titleValue}</criteria>
234         <criteria>OPTIONAL { ?title bf:formDesignation ?formDesignation}</criteria>
235         <criteria>OPTIONAL { ?title bf:partNumber ?partNumber}</criteria>
236         <criteria>OPTIONAL { ?title bf:partTitle ?partTitle}</criteria>
237         <criteria>OPTIONAL { ?title bf:subtitle ?subtitle}</criteria>
238         <criteria>OPTIONAL { ?title bf:titleAttribute ?titleAttribute}</criteria>
239         <criteria>OPTIONAL { ?title bf:titleQualifier ?titleQualifier}</criteria>
240         <criteria>OPTIONAL { ?title bf:titleSource ?titleSource}</criteria>
241         <criteria>OPTIONAL { ?title bf:titleType ?titleType}</criteria>
242         <criteria>OPTIONAL { ?title bf:titleVariationDate ?titleVariationDate}</criteria>
243         <index type="bf.title">?title bf:titleValue %v FILTER(contains(%v, %s))</index>
244         <index type="bf.subtitle">?title bf:subtitle %v FILTER(contains(%v, %s))</index>
245         <index type="bf.parttitle">?title bf:partTitle %v FILTER(contains(%v, %s))</index>
246         <index type="any">?title ?rel  %v FILTER(contains(str(%v), %s))</index>
247     </db>
248     <!-- A hack to be able to look at any triplet in the base -->
249     <db path="node" schema="sparql-results">
250       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
251       <prefix>bf: http://bibframe.org/vocab/</prefix>
252       <form>SELECT ?node ?rel ?obj</form>
253       <index type="any">?node ?rel ?obj FILTER( str(?node) = %s )</index>
254     </db>
255     <!-- A way to see which triplets refers to a given uri. -->
256     <db path="ref" schema="sparql-results">
257       <prefix>rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns</prefix>
258       <prefix>bf: http://bibframe.org/vocab/</prefix>
259       <form>SELECT ?node ?rel ?obj</form>
260       <index type="any">?node ?rel ?obj FILTER( str(?obj) = %s )</index>
261     </db>
262   </filter>
263   <filter type="log">
264     <message>http</message>
265     <category apdu="true"/>
266   </filter>
267   <filter type="http_client">
268     <x-forwarded-for>true</x-forwarded-for>
269   </filter>
270 </filters>