EPrints Technical Mailing List Archive

Message: #00925


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

[EP-tech] Searching in EP3.2


Confused here.... I'm trying to restrict a search, and it's returning 0 results when it should return 19:

This works:

  my $dsd = $session->get_repository->get_dataset("dark_archive");
  my $searchexp2 = EPrints::Search->new(
                                      satisfy_all => 1,
                                      session     => $session,
                                      dataset     => $dsd,
                                     );    # dark archive
  $searchexp2->add_field($dsd->get_field("special_field"),  'FALSE');
  $searchexp2->add_field($dsd->get_field("special_field2"), '');
  my $results2 = $searchexp2->perform_search;
  my $count = $results2->count;
  print "$count records to check\n";
  foreach my $epid (sort @{$results2->ids})
  {
    my $ep = $dso->dataobj($epid);
    next unless $ep->value("field3") eq 'Foo Bar';
    ## do stuff
  }

... this produces 19 results
(notice the 'next' statement in the foreach loop.... a wasteful way of doing things.)

When I try:

  my $dsd = $session->get_repository->get_dataset("dark_archive");
  my $searchexp2 = EPrints::Search->new(
                                      satisfy_all => 1,
                                      session     => $session,
                                      dataset     => $dsd,
                                     );    # dark archive
  $searchexp2->add_field($dsd->get_field("special_field"), 'FALSE');
  $searchexp2->add_field($dsd->get_field("special_field2"), '');
  $searchexp2->add_field($dsd->get_field("field3"), 'Foo bar');
  my $results2 = $searchexp2->perform_search;
  my $count = $results2->count;
  print "$count records to check\n";
  foreach my $epid (sort @{$results2->ids})
  {
    my $ep = $dso->dataobj($epid);
    ## do stuff
  }

... this produces 0 results!

Why?


--

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.