[EP-tech] Re: Writing slightly more complex searches

Alan.Stiles alan.stiles at open.ac.uk
Fri Aug 22 14:57:46 BST 2014

Programmatically, could you do

List1 = search (A and B)
List 2 = search (A and C)
ResultList = List 1 + List 2

Possibly slow and clunky though...


-----Original Message-----
From: Ian Stuart [mailto:Ian.Stuart at ed.ac.uk]
Sent: 22 August 2014 14:36
To: eprints
Subject: [EP-tech] Writing slightly more complex searches

Gentle-beings, wonder-folk, and those that lurk....

I'm trying to do

   search for A and (B or C)

For example:

   search for userid=42
          AND (ispublished = 'pub' OR refereed = 'TRUE')

Now, before adding in the "OR" bit, setting up the search is simple:

   $dso = $session->get_repository->get_dataset('archive');
   $searchexp1 = EPrints::Search->new(
      satisfy_all => 1,
      session     => $session,
      dataset     => $dso,
   $searchexp1->add_field( $dso->get_field('userid'),      '42', );
   $searchexp1->add_field( $dso->get_field('ispublished'), 'pub', 'EQ' );

.... but adding in referred causes a problem:
   $searchexp1->add_field( $dso->get_field('userid'),      '42', );
   $searchexp1->add_field( $dso->get_field('ispublished'), 'pub', 'EX' );
   $searchexp1->add_field( $dso->get_field('refereed'),    'TRUE' );

(this is "A AND B AND C")

Any tips?


Ian Stuart.
Developer: ORI, RJ-Broker, and OpenDepot.org Bibliographics and Multimedia Service Delivery team, EDINA, The University of Edinburgh.


This email was sent via the University of Edinburgh.

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/
-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority.

More information about the Eprints-tech mailing list