EPrints Technical Mailing List Archive

Message: #01371


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Creating searches in EPrints?


On Fri, 2012-12-07 at 12:14 +0000, Ian Stuart wrote:
> Is this documented anywhere? I'm not finding anything...
> 
> If I have the following defined for an eprint dataObject:
> 
>          {
>              'name' => 'broker',
>              'type' => 'compound',
>              'multiple' => 1,
>              'fields' => [
>                    { sub_name => 'orgid',    'type' => 'text' },
>                    { sub_name => 'orgname',  'type' => 'text' },
>                    { sub_name => 'repoid',   'type' => 'text' },
>                    { sub_name => 'reponame', 'type' => 'text' },
>                    { sub_name => 'sword',    'type' => 'boolean' },
>                    { sub_name => 'sent',     'type' => 'time', },
>                    { sub_name => 'return',   'type' => 'url' },
>                    { sub_name => 'live',     'type' => 'time', },
>                    { sub_name => 'target',   'type' => 'url' },
>                    { sub_name => 'note',     'type' => 'text' },
>                    { sub_name => 'archiver', 'type' => 'boolean' },
>                          ],
>            },
> 
> I should be able to create a search thus:
> 
>    my $dso = $session->get_repository->get_dataset("archive");
>    my $searchexp1 = EPrints::Search->new(
>      satisfy_all => 1,
>      session     => $session,
>      dataset     => $dso,
>    );
>    $searchexp1->add_field( $dso->get_field("broker_sword"), 'TRUE' );
>    $searchexp1->add_field( $dso->get_field("broker_sent"),  '2000-' );
>    $searchexp1->add_field( $dso->get_field("broker_live"),  '' );
>    my $results1 = $searchexp1->perform_search;
> 
> As I understand it, this should list only those records where one or 
> more of the broker elements has the sub_field "sword" set true, and the 
> sub_field "sent" defined and after the year 2000, and the sub_field 
> "live" is empty
> .... unfortunately, I'm getting records where sub_field "sword" is true, 
> but none of the broker elements have a "sent" sub_field
> 
> Is there anything out there?
> 

To help debug,
print $searchexp1->get_conditions->describe;

To see what you're getting.

On more recent versions you can use '..' as the range selector, in case
it's a problem with understanding '-' with just a year (or maybe
"2000-01-01-" ?).

/Tim.

Attachment: signature.asc
Description: This is a digitally signed message part