EPrints Technical Mailing List Archive

Message: #06447


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

Re: [EP-tech] Virtual Field derived by SQL query or code and available for searching.


Thanks Adam.

 

I'll look into the full_text_status field.  I could have sworn I looked into that once before, but it was a long time ago (and many projects ago).  So I'll give it a whirl once more.   If this works as needed then I think we'll go from there.

 

Thanks again.

-Brian.

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Adam Field
Sent: Thursday, April 13, 2017 5:46 PM
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Virtual Field derived by SQL query or code and available for searching.

 

 

Hi Brian

 

                Virtual fields have no value stored in the database.  Therefore, you can't search on them.  The virtualwithvalue field was created to allow virtual fields to write back to the non-virtual fields they are based on, which can be useful in some situations.  From your code below, I believe that calling set_value will cause a stack overflow, as $eprint->set_value('fulltext', 'TRUE') will make a call to $eprint->set_value('fulltext', 'TRUE') until the computer runs out of stack space.

 

                In a default eprints repository, there's already a field for this -- full_text_status.  Try adding that to your search configuration and see what happens :)  It's managed as an automatic field, rather than a virtual one, which sounds like what you need.  There's a training video for that, too: MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be https://wiki.eprints.org/w/Training_Video:Automatic_Fields

 

                See:

 

 

                ...as an aside, I've always thought that the behaviour of this field is wrong.  It should be a multiple field, so that we can distinguish between items that have only restricted documents, items that have only public documents and items that have both.

 

--

Adam

 

 

On 13 Apr 2017, at 18:10, Brian D. Gregg <bdgregg@pitt.edu> wrote:



All,

 

I've delved into testing Adam Fields excellent video on Virtual fields (MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be http://www.youtube.com/watch?v=GjeWcewJA5o) which works perfectly for creating a derived "display" only value visible within the abstract page, however when adding the newly created Virtualwithvalue type field into the advanced search form and searching against it returns zero results (at least on our system here).  I expect that there is some tweak needed or some additional voodoo needed to get that to work correctly which I think I've only seen the tip of the iceberg at this point.

 

What I've been asked to investigate is adding a field to the advanced search that would indicate if the Eprint has full text or not (to allow for searching of only full text items) as we have both metadata only and full text items in our IR and the wish is to only search items that contain full text.

 

I've been able to create a virtual field as follows:

 

In my zz_local_fields.pl file I've created the get_value and set_value properties as follows base upon Adam's video and some code:

    name => 'fulltext',

    type => 'virtualwithvalue',

    virtual => 1,

    get_value => sub

    {

        my ($eprint) = @_;

        my $val = '';

        if ( $eprint->get_all_documents == 0 )

        {

           $val = "FALSE";

           return $val;

        } else {

           $val = "TRUE";

           return $val;

        }

    },

    set_value => sub

    {

        my ($eprint, $value) = @_;

        if ( $eprint->get_all_documents == 0 )

        {

            $eprint->set_value('fulltext',"FALSE");

        } else {

            $eprint->set_value('fulltext',"TRUE");

        }

    }

 

This "derived" field works perfectly within the abstract view.  The definition of an Eprint containing full text or not seems to be if $eprint->get_all_documents == 0 or not.  I expect we could create an SQL query to extract this or use some code.  Obviously we could create a regular field and populate it with the use of eprint_automatic_fields.pl but the value "TRUE"|"FALSE" could be easily derived using code or SQL query instead. 

 

We'd like to extend this virtual field a bit so that the same field can also be searched against in the advanced search.  Has anyone implemented something along those lines?  Or am I missing something that is maybe too obvious for me to see?

 

A discussion with a colleague of mine resulted in his suggestion that we may need to create a type of Virtualfromsql.pm where we create a virtual field which is derived from an SQL search, has anyone tried or had any experience with this kind of approach?

 

-Thanks,

Brian.

 

Brian D. Gregg

Solutions Architect

University of Pittsburgh | University Library System

Address: 7500 Thomas Blvd.  Room 129 Pittsburgh, PA 15208

Tel: (412) 648-3264 | Email: bdgregg@pitt.edu | Fax: (412) 648-3585

MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be https://orcid.org/0000-0001-6541-4544

 

*** Options: MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be http://www.eprints.org/tech.php/
*** EPrints community wiki: MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be http://wiki.eprints.org/
*** EPrints developers Forum: MailScanner has detected a possible fraud attempt from "na01.safelinks.protection.outlook.com" claiming to be http://forum.eprints.org/