EPrints Technical Mailing List Archive

Message: #03949


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

[EP-tech] Re: Search API and name fields (or compound)


Hi Adam,

Thanks for your answer.

Your script will be useful to make stats for the library staff.

For what I wanted to do, I have found another way.
I am not sure if it is a stable solution, but it works on our data...

   my $search = new EPrints::Search( session=>$session,
   dataset=>$dataset );

   #---- 1. first find items where the author field is NOT null

   $search->add_field(
      fields => $dataset->get_field('author'),
      match => 'SET',
      value => '' # value is needed even if it is not really used...
   );

   my $authors_OK = $search->perform_search;

   #---- 2. And substract it to the list of all items

   my $list = $dataset->search(); # All items

   $list = $list->remainder( $authors_OK );

BTW, it could be useful to have new match methods to use in scripts (there would be of little use to build search forms). By instance :

 * NULL => performs sql "IS NULL"
 * BLANK => is null || equals empty string
 * ZERO =>  is null || equals empty string || equals 0
 * and the negative forms NONULL, NOBLANK, NOZERO...

Best regards,
GF



Le 18/02/2015 17:13, Field A.N. a écrit :
I don't think this is possible, I'm afraid.  The way I approach this kind of problem is to iterate over the repository and generate a report.  You could do worse than start with the SCONUL report and modify it to do what you want (save the IDs of items with no author, rather than counting the documents).

http://wiki.eprints.org/w/SCONUL_Report


--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services




On 18 Feb 2015, at 10:30, Gilles Fournié wrote:

Hi,

I am trying to write a script to do a search on a dataset.
I would like to find entries where the author field has not been set.

I tried :

    $search->add_field(
       fields => $dataset->get_field('author'),
       match => 'EX',
       value => {family=>'', given=>''}
    );

and

    $search->add_field(
       fields => $dataset->get_field('author'),
       match => 'EX',
       value => {family=>'NULL', given=>'NULL'}
    );

but neither work (they find nothing although there are database entries
with both author_family and author_given null).

Could anybody tell me how I should write the condition ?

Thanks,
GF

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

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