From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Metadata::ByInode::Search

DESCRIPTION

this is not meant to be used directly. this is part of Metadata::ByInode

search()

Parameter is a hash ref with metadata keys and values you want to look up by. Imagine you want to search for all metadata for a file whose absolute path you know.

my $RESULT = $mbi->search ({
filename => 'pm',
abs_loc => '/home/leo/devel/Metadata-ByInode/lib'
},);

Returns hash of hashes. Key is inode.

search() is NOT an exact match. it is a LIKE function by default. If you want some keys to be exact then you must defined the key as:

my $RESULT = $mbi->search ({
filename => 'pm',
'abs_loc:exact' => '/home/leo/devel/Metadata-ByInode/lib'
},);

This would make the abs_loc be exactly '/home/leo/devel/Metadata-ByInode/lib', and the filename would match '*pm*'.

Notice that this is the same thing:

my $RESULT = $mbi->search ({
'filename:like' => 'pm',
'abs_loc:exact' => '/home/leo/devel/Metadata-ByInode/lib'
},);

example output:

$RESULT: {
'7496560' => {
abs_loc => '/home/leo/devel/Metadata-ByInode/lib/Metadata',
filename => 'ByInode.pm',
ondisk => '1164911227'
},
'7725851' => {
abs_loc => '/home/leo/devel/Metadata-ByInode/lib/Metadata/ByInode',
filename => 'Search.pm',
ondisk => '1164911227'
},
'7725852' => {
abs_loc => '/home/leo/devel/Metadata-ByInode/lib/Metadata/ByInode',
filename => 'Index.pm',
ondisk => '1164911227'
}
}

search_results()

Return the search results in an array ref, each array ref has an anon hash with file details as:

$search_results = [
{ abs_loc => '/tmp', filename => 'file1', ondisk => 1231231231, inode => 234, abs_path => '...' },
{ abs_loc => '/tmp/dir', filename => 'file2', ondisk => 1231231231, inode => 143, abs_path => '...' },
];

If no search results are present beacuse nothing was found, returns [] anon array ref, empty.

If no search was run, returns undef.

results_count()

If a search was run, how many results are there, returns number. if nothing was found, returns 0

Returns undef if no search was run.

SEE ALSO

Metadata::ByInode and Metadata::ByInode::Indexer

AUTHOR

Leo Charre <leo@leocharre.com>