Created
April 10, 2014 13:46
-
-
Save MagnusEnger/10383970 to your computer and use it in GitHub Desktop.
Catmandu Atom ingest v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Catmandu::Importer::Atom; | |
use Catmandu::Store::ElasticSearch; | |
use Data::Dumper; | |
use Modern::Perl; | |
my $feed = 'http://planet.code4lib.org/atom.xml'; | |
my $importer = Catmandu::Importer::Atom->new( url => $feed ); | |
my $store = Catmandu::Store::ElasticSearch->new( index_name => 'dbabel' ); | |
$store->bag->delete_all; | |
$store->bag->add_many( $importer ); | |
$store->bag->commit; | |
my $hits = $store->bag->search( query => 'library' )->to_array; | |
foreach my $hit ( @{ $hits } ) { | |
say "* ", $hit->{'_id'}, " ", $hit->{'title'}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment