NAME
Metadata::DB::Search - search the indexed metadata
SYNOPSIS
use Metadata::DB::Search;
use Metadata::DB;
my $s = Metadata::DB::Search->new({ DBH => $dbh });
$s->search({
age => 24,
'first_name:like' => 'jo',
'speed:morethan' => 40,
});
$s->ids_count or die('nothing found');
for(@$ids) {
my $o = new Metadata::DB({ DBH => $dbh, id => $_ });
}
EXAMPLE 2
my $s = Metadata::DB::Search->new({ DBH => $dbh });
$s->search_params_add( age => 24 );
$s->search_params_add( 'first_name:like' =>'jo' );
$s->search;
my @matching_ids = @{ $s->ids };
for my $id ( @matching_ids ){
}
EXAMPLE 3
What if you want to search other metadata table?
$s->table_name_metadata
$s->search({
age => 24,
'first_name:like' => 'jo',
});
METHODS
search_params_count()
returns how many search params we have
search_params_add()
constriction_keys()
search()
optional argument is a hash ref with search params these are key value pairs the value can be a string or an array ref
$s->search({
age => 25,
'name:exact' => ['larry','joe']
});
Possible search types for each attribute are like, exact, morethan, lessthan, default is like.
_select_limit()
experimental, arg is number, may help speed up searches if set, possible num is 100?
ids()
returns array ref of matching ids, results, in metadata table that meet the criteria