@@ -174,22 +174,24 @@ dependency.
174
174
175
175
``` sh
176
176
curl -XPOST https://fastapi.metacpan.org/v1/release/_search -d ' {
177
- "size": 5000,
178
- "fields": [ "distribution" ],
179
- "filter": {
180
- "and": [
181
- { "term": { "dependency.module": "MooseX::NonMoose" } },
182
- { "term": {"maturity": "released"} },
183
- { "term": {"status": "latest"} }
184
- ]
185
- }
177
+ "size" : 5000,
178
+ "fields" : [ "distribution" ],
179
+ "query" : {
180
+ "bool" : {
181
+ "must" : [
182
+ { "term" : { "dependency.module" : "MooseX::NonMoose" } },
183
+ { "term" : { "maturity" : "released" } },
184
+ { "term" : { "status" : "latest" } }
185
+ ]
186
+ }
187
+ }
186
188
}'
187
189
```
188
190
189
- _ Note it is also possible to use these queries in GET requests (useful for cross-domain JSONP requests) by appropriately encoding the JSON query into the ` source ` parameter of the URL. For example the query above [ would become] ( https://fastapi.metacpan.org/v1/release/_search?source=%7B%22query%22%3A%7B%22match_all%22%3A%7B%7D%7D%2C%22size%22%3A5000%2C%22fields%22%3A%5B%22distribution%22%5D%2C%22filter%22%3A%7B%22and%22%3A%5B%7B%22term%22%3A%7B%22release.dependency.module%22%3A%22MooseX%3A%3ANonMoose%22%7D%7D%2C%7B%22term%22%3A%7B%22release.maturity%22%3A%22released%22%7D%7D%2C%7B%22term%22%3A%7B%22release.status%22%3A%22latest%22%7D%7D%5D%7D%7D ) :_
191
+ _Note it is also possible to use these queries in GET requests (useful for cross-domain JSONP requests) by appropriately encoding the JSON query into the `source` parameter of the URL. For example the query above [would become](https://fastapi.metacpan.org/v1/release/_search?source=%7B%0A%20%20%20%20%22size%22%20%3A%205000%2C%0A%20%20%20%20%22fields%22%20%3A%20%5B%20%22distribution%22%20%5D%2C%0A%20%20%20%20%22query%22%20%3A%20%7B%0A%20%20%20%20%20%20%20%20%22bool%22%20%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22must%22%20%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%22term%22%20%3A%20%7B%20%22dependency.module%22%20%3A%20%22MooseX%3A%3ANonMoose%22%20%7D%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%22term%22%20%3A%20%7B%20%22maturity%22%20%3A%20%22released%22%20%7D%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%22term%22%20%3A%20%7B%20%22status%22%20%3A%20%22latest%22%20%7D%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D):_
190
192
191
193
```
192
- curl 'https://fastapi.metacpan.org/v1/release/_search?source=%7B%22query%22%3A%7B%22match_all% 22%3A%7B%7D%7D% 2C%22size%22%3A5000%2C% 22fields%22%3A%5B%22distribution%22%5D%2C%22filter% 22%3A%7B%22and% 22%3A%5B%7B%22term%22%3A%7B%22release.dependency. module%22%3A%22MooseX%3A%3ANonMoose%22%7D%7D%2C%7B%22term%22%3A%7B%22release.maturity% 22%3A%22released%22%7D%7D%2C%7B%22term%22%3A%7B%22release.status% 22%3A%22latest%22%7D%7D%5D%7D %7D'
194
+ curl 'https://fastapi.metacpan.org/v1/release/_search?source=%7B%0A%20%20%20%20%22size% 22%20% 3A%205000% 2C%0A%20%20%20%20% 22fields%22%20% 3A%20% 5B%20% 22distribution%22%20% 5D%2C%0A%20%20%20%20%22query% 22%20% 3A%20% 7B%0A%20%20%20%20%20%20%20%20%22bool% 22%20% 3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22must%22%20%3A%20% 5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 7B%20% 22term%22%20% 3A%20% 7B%20%22dependency. module%22%20% 3A%20% 22MooseX%3A%3ANonMoose%22%20% 7D%20% 7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 7B%20% 22term%22%20% 3A%20% 7B%20%22maturity% 22%20% 3A%20% 22released%22%20% 7D%20% 7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 7B%20% 22term%22%20% 3A%20% 7B%20%22status% 22%20% 3A%20% 22latest%22%20% 7D%20% 7D%0A%20%20%20%20%20%20%20%20%20%20%20%20% 5D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A %7D'
193
195
```
194
196
195
197
### [ The size of the CPAN unpacked] ( https://github.com/metacpan/metacpan-examples/blob/master/scripts/file/5-size-of-cpan.pl )
@@ -199,64 +201,68 @@ curl 'https://fastapi.metacpan.org/v1/release/_search?source=%7B%22query%22%3A%7
199
201
200
202
``` sh
201
203
curl -XPOST https://fastapi.metacpan.org/v1/release/_search? size=100 -d ' {
202
- "query": {
203
- "range" : {
204
- "date" : {
205
- "gte" : "2010-06-05T00:00:00",
206
- "lte" : "2011-06-05T00:00:00"
204
+ "query" : {
205
+ "range" : {
206
+ "date" : {
207
+ "gte" : "2010-06-05T00:00:00",
208
+ "lte" : "2011-06-05T00:00:00"
209
+ }
207
210
}
208
- }
209
- },
210
- "fields": ["license", "name", "distribution", "date", "version_numified"]
211
+ },
212
+ "fields": [ "license", "name", "distribution", "date", "version_numified" ]
211
213
}'
212
214
```
213
215
214
216
### Aggregate by license:
215
217
216
218
``` sh
217
219
curl -XPOST https://fastapi.metacpan.org/v1/release/_search -d ' {
218
- "query": {
219
- "match_all": {}
220
+ "query" : {
221
+ "match_all" : {}
220
222
},
221
- "aggs": {
222
- "license": {
223
- "terms": {
224
- "field": "license"
223
+ "aggs" : {
224
+ "license" : {
225
+ "terms" : {
226
+ "field" : "license"
225
227
}
226
228
}
227
229
},
228
- "size": 0
230
+ "size" : 0
229
231
}'
230
232
```
231
233
232
234
### Most used file names in the root directory of releases:
233
235
234
236
``` sh
235
237
curl -XPOST https://fastapi.metacpan.org/v1/file/_search -d ' {
236
- "query": { "filtered":{"query":{"match_all":{}},"filter":{"term":{"level":0}}}
237
- },
238
- "aggs": {
239
- "license": {
240
- "terms": {
241
- "size":100,
242
- "field":"name"
243
- } } },
244
- "size":0
238
+ "query" : {
239
+ "term" : { "level" : 0 }
240
+ },
241
+ "aggs" : {
242
+ "license" : {
243
+ "terms" : {
244
+ "size" : 100,
245
+ "field" : "name"
246
+ }
247
+ }
248
+ },
249
+ "size" : 0
245
250
}'
246
251
```
247
252
248
253
### Find all releases that contain a particular version of a module:
249
254
250
255
``` sh
251
256
curl -XPOST https://fastapi.metacpan.org/v1/file/_search -d ' {
252
- "query": { "filtered":{
253
- "query":{"match_all":{}},
254
- "filter":{"and":[
255
- {"term":{"module.name":"DBI::Profile"}},
256
- {"term":{"module.version":"2.014123"}}
257
- ]}
258
- }},
259
- "fields":["release"]
257
+ "query" : {
258
+ "bool" : {
259
+ "must" : [
260
+ { "term" : { "module.name" : "DBI::Profile" } },
261
+ { "term" : { "module.version" : "2.014123" } }
262
+ ]
263
+ }
264
+ },
265
+ "fields" : [ "release" ]
260
266
}'
261
267
```
262
268
@@ -277,50 +283,61 @@ Note that "size" should be the number of distributions you are looking for.
277
283
``` sh
278
284
lynx --dump --post_data https://fastapi.metacpan.org/v1/release/_search << EOL
279
285
{
280
- "query" : { "terms" : { "distribution" : [
281
- "Mojolicious",
282
- "MetaCPAN-API",
283
- "DBIx-Class"
284
- ] } },
285
- "filter" : { "term" : { "status" : "latest" } },
286
+ "query" : {
287
+ "bool" : {
288
+ "must" : [
289
+ {
290
+ "terms" : {
291
+ "distribution" : [
292
+ "Mojolicious",
293
+ "MetaCPAN-API",
294
+ "DBIx-Class"
295
+ ]
296
+ }
297
+ },
298
+ { "term" : { "status" : "latest" } }
299
+ ]
300
+ }
301
+ },
286
302
"fields" : [ "distribution", "version" ],
287
- "size" : 3
303
+ "size" : 3
288
304
}
289
305
EOL
290
306
```
291
307
292
308
### Get a list of all files where the directory is false and the path is blank
293
309
``` sh
294
310
curl -XPOST https://fastapi.metacpan.org/v1/file/_search -d ' {
295
- "query": {
296
- "match_all" : {}
297
- },
298
- "size": 1000 ,
299
- "fields": [ "name", "status", "directory", "path", "distribution" ],
300
- "filter": {
301
- "and": [
302
- { "term": { "directory": false } }, { "term" : { "path" : "" } }
303
- ]
304
- }
311
+ "query" : {
312
+ "bool" : {
313
+ "must" : [
314
+ { "term" : { "directory" : false } } ,
315
+ { "term" : { "path" : "" } }
316
+ ]
317
+ }
318
+ },
319
+ "size" : 1000,
320
+ "fields" : [ "name", "status", "directory", "path", "distribution" ],
305
321
}'
306
322
```
307
323
308
324
### List releases which have an email address for a bugtracker, but not an url
309
325
``` sh
310
326
curl -XPOST https://fastapi.metacpan.org/v1/release/_search -d ' {
311
- "query": {
312
- "match_all": {}
313
- },
314
- "size": 10,
315
- "fields": [ "name", "resources.bugtracker.mailto" ],
316
- "filter": {
317
- "and": [
318
- { "term": {"maturity": "released"} },
319
- { "term": {"status": "latest"} },
320
- { "exists" : { "field" : "resources.bugtracker.mailto" } },
321
- { "missing" : { "field" : "resources.bugtracker.web" } }
322
- ]
323
- }
327
+ "query" : {
328
+ "bool" : {
329
+ "must" : [
330
+ { "term" : {"maturity" : "released"} },
331
+ { "term" : {"status" : "latest"} },
332
+ { "exists" : { "field" : "resources.bugtracker.mailto" } }
333
+ ],
334
+ "must_not" : [
335
+ { "exists" : { "field" : "resources.bugtracker.web" } }
336
+ ]
337
+ }
338
+ },
339
+ "size": 10,
340
+ "fields": [ "name", "resources.bugtracker.mailto" ],
324
341
}'
325
342
```
326
343
@@ -330,18 +347,19 @@ curl -XPOST https://fastapi.metacpan.org/v1/release/_search -d '{
330
347
### Search the current PDL documentation for the string ` axisvals `
331
348
``` sh
332
349
curl -XPOST https://fastapi.metacpan.org/v1/file/_search -d ' {
333
- "query" : { "filtered" : {
334
- "query" : {
335
- "query_string" : {
336
- "query" : "axisvals",
337
- "fields" : [ "pod.analyzed", "module.name" ] }
338
- },
339
- "filter" : { "and" : [
340
- { "term" : { "distribution" : "PDL" } },
341
- { "term" : { "status" : "latest" } }
342
- ]}
343
- }},
350
+ "query" : {
351
+ "bool" : {
352
+ "must" : [
353
+ "query_string" : {
354
+ "query" : "axisvals",
355
+ "fields" : [ "pod.analyzed", "module.name" ]
356
+ },
357
+ { "term" : { "distribution" : "PDL" } },
358
+ { "term" : { "status" : "latest" } }
359
+ ]
360
+ }
361
+ },
344
362
"fields" : [ "documentation", "abstract", "module.name" ],
345
363
"size" : 20
346
- }'
364
+ }'
347
365
```
0 commit comments