CPAN-API/cpan-api — Issue #138: /module/ returns all dist files instead of limiting to modules
Author: rwstauner
Created: 2011-10-17 03:09:54+00:00
State: open

@kentl, @oalders and i were trying to get the "provides" list for a dist...

I was trying something along these lines in the explorer:

```
{"query":{"match_all":{}},
"size": 999999,
"filter": {
"and":[
{"term":{"status":"latest"} },
{"term":{"distribution":"Moose"}}
]
}, "fields": ["module.name"]
}
```

and found files like "TODO", "CHANGES", and ".spec" in the results.

It seems to me like /module/_search is returning all files without filtering for module-like files.

Adding these two filters got me closer, though I know the path-prefix would not always correct:

```
{"term":{"mime":"text/x-script.perl-module"}},
{"prefix":{"path":"lib/"}}
```

oalders pointed me to an iCPAN example which has examples for possibly useful filters (like authorized, indexed, etc).
https://github.com/oalders/iCPAN/blob/master/perl/lib/iCPAN.pm#L414

Should the /module/ api be applying some filters by default to limit the results?