how to restrict to 'cpan' only?

11 views
Skip to first unread message

Gabor Szabo

unread,
Feb 14, 2013, 9:54:56 AM2/14/13
to cpan...@googlegroups.com

Using the MetaCPAN::API my ultimate goal is to fetch the oldest modules and the oldest modules still on CPAN.
I manged to fetch a date-range, but I could not restrict the status to 'cpan'. It keeps returning entries on 'backpan' as well.

Here is the query I am using:

        my $r = $mcpan->post(
            'release',
            {
                query  => {
                    match_all => {},
#this fails                        status    => 'cpan',  # or 'backpan'
                    range => {
#this fails                        status    => 'cpan',  # or 'backpan'
                        'release.date' => {
                            "from" => "2011-05-05T00:00:00",
                            "to" => "1995-10-05T00:00:00",
                        }
                    },
                 },
# this does not have an impact
                filter => {
                    "term" => { status    => 'cpan' },  # or 'backpan'
                },
                fields => [ 'distribution', 'date', 'version', 'download_url', 'status' ],
                size => 2,
            },
        );


So what am I doing wrong?

Gabor

on...@netcubed.de

unread,
Feb 24, 2013, 12:54:31 PM2/24/13
to cpan...@googlegroups.com
Hi Gabor,

this is probably what you are looking for:

curl -XPOST api.metacpan.org/release/_search -d '{
"query" : {
"constant_score" : {
"filter" : {
"and" : [
{
"range" : {
"release.date" : {
"to" : "2011-05-05T00:00:00",
"from" : "1995-10-05T00:00:00"
}
}
},
{
"not" : {
"term" : {
"status" : "backpan"
}
}
}
]
}
}
},
"fields" : ["distribution", "date", "status"],
"size" : 2
}'

Notice the "from" has to be the earlier date. Use a boolean "and"
filter to
merge the range and status query. I felt like you might want everything
but
"backpan". If that is not true, remove the "not" query and change
"status" to
"cpan".

Best,
Moritz
> --
> You received this message because you are subscribed to the Google
> Groups "CPAN-API" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cpan-api+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out [1].
>
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out

Reply all
Reply to author
Forward
0 new messages