[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Adam Field
Sent: Thursday, April 13, 2017 5:46 PM
To: eprints-tech at 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: https://wiki.eprints.org/w/Training_Video:Automatic_Fields<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FTraining_Video%3AAutomatic_Fields&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=VWCv6%2BUpjNmRmE5IE%2FnCEL1DiyZUfjF%2FzeNzIN6iZI0%3D&reserved=0>



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


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


I've delved into testing Adam Fields excellent video on Virtual fields (http://www.youtube.com/watch?v=GjeWcewJA5o<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGjeWcewJA5o&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=zm8IPVlmoBzkdZgaWA%2B4JR8BVqrTm6hRvBUyVXXXgLU%3D&reserved=0>) 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 )
        } else {

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?


Brian D. Gregg
Solutions Architect
University of Pittsburgh | University Library System
Address: 7500 Thomas Blvd.  Room 129 Pittsburgh, PA 15208<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmaps.google.com%2Fmaps%3Fq%3D7500%2BThomas%2BBlvd%2C%2BPittsburgh%2C%2BPA%26hl%3Den%26sll%3D41.117935%2C-77.604698%26sspn%3D7.662465%2C13.73291%26oq%3D7500%2BTho%26t%3Dh%26hnear%3D7500%2BThomas%2BBlvd%2C%2BPittsburgh%2C%2BPennsylvania%2B15208%26z%3D17&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=VvVkLzxIHLH0xiM7AUgtRxFGEnzGjLqo5YYDNGDiGLU%3D&reserved=0>
Tel: (412) 648-3264 | Email: bdgregg at pitt.edu<mailto:bdgregg at pitt.edu> | Fax: (412) 648-3585

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=DTVkOFTgOZyClL%2FCMktLZS5y9yg9V1cuxB0%2BgY%2F56Jw%3D&reserved=0>
*** Archive: http://www.eprints.org/tech.php/<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=nLytwgGkvj0VgYYZBwKQ3tzUDQh1xcs1dDSoutZcCc4%3D&reserved=0>
*** EPrints community wiki: http://wiki.eprints.org/<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=cTVrMec0P9TIlOEE9FfYNLcKtkLsFMFABgKPabAuT7Q%3D&reserved=0>
*** EPrints developers Forum: http://forum.eprints.org/<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fforum.eprints.org%2F&data=01%7C01%7Cbdgregg%40pitt.edu%7C778d55f5bbc84e3403c608d482b7487b%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=xrzwmLsdCp4CzfiT4kkGntZlOjLDvM4av0RUbJqXzps%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20170418/7125c39a/attachment-0001.html