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

John Salter J.Salter at leeds.ac.uk
Fri Aug 22 15:24:11 BST 2014


Or do (Friday afternoon monkey-code)
$list1 = search1: userid = 42
$list2 = search2: (ispublished = 'pub' OR refereed = 'TRUE')

$new_list = $list1->intersect( $list2 );

[From: http://wiki.eprints.org/w/API:EPrints/List]

I'm guessing you're not on a Xapian-enabled repo..?

Cheers,
John

-----Original Message-----
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Alan.Stiles
Sent: 22 August 2014 14:58
To: eprints-tech at ecs.soton.ac.uk
Subject: [EP-tech] Re: Writing slightly more complex searches

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...

Alan

-----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.

http://edina.ac.uk/

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.

*** 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/



More information about the Eprints-tech mailing list