Skip to content

Instantly share code, notes, and snippets.

@MagnusEnger
Created April 10, 2014 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MagnusEnger/10383970 to your computer and use it in GitHub Desktop.
Save MagnusEnger/10383970 to your computer and use it in GitHub Desktop.
Catmandu Atom ingest v1
#!/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