<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>Hi Brian</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Virtual fields have no value stored in the database. &nbsp;Therefore, you can't search on them. &nbsp;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. &nbsp;From your code below, I believe that calling set_value will cause a stack overflow, as $eprint-&gt;set_value('fulltext', 'TRUE') will make a call to $eprint-&gt;set_value('fulltext', 'TRUE') until the computer runs out of stack space.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In a default eprints repository, there's already a field for this -- full_text_status. &nbsp;Try adding that to your search configuration and see what happens :) &nbsp;It's managed as an automatic field, rather than a virtual one, which sounds like what you need. &nbsp;There's a training video for that, too:&nbsp;<a href="https://wiki.eprints.org/w/Training_Video:Automatic_Fields">https://wiki.eprints.org/w/Training_Video:Automatic_Fields</a></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>See:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/eprints/eprints/blob/392474eec1b8125a66ed2d3e12b02aeb67dc07c4/lib/defaultcfg/cfg.d/eprint_fields_automatic.pl#L30">https://github.com/eprints/eprints/blob/392474eec1b8125a66ed2d3e12b02aeb67dc07c4/lib/defaultcfg/cfg.d/eprint_fields_automatic.pl#L30</a></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...as an aside, I've always thought that the behaviour of this field is wrong. &nbsp;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.</div><div><br></div><div>--</div><div>Adam</div><div><br></div><br><div><div>On 13 Apr 2017, at 18:10, Brian D. Gregg &lt;<a href="mailto:bdgregg@pitt.edu">bdgregg@pitt.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->

<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1"><p class="MsoNormal">All,<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">I've delved into testing Adam Fields excellent video on Virtual fields (<a href="http://www.youtube.com/watch?v=GjeWcewJA5o">http://www.youtube.com/watch?v=GjeWcewJA5o</a>) 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). &nbsp;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.
<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">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.<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">I've been able to create a virtual field as follows:<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">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:<o:p></o:p></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; name =&gt; 'fulltext',<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; type =&gt; 'virtualwithvalue',<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; virtual =&gt; 1,<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; get_value =&gt; sub<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($eprint) = @_;<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $val = '';<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( $eprint-&gt;get_all_documents == 0 )<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $val = "FALSE";<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $val;<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$val = "TRUE";<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $val;<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; },<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; set_value =&gt; sub<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($eprint, $value) = @_;<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( $eprint-&gt;get_all_documents == 0 )<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $eprint-&gt;set_value('fulltext',"FALSE");<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $eprint-&gt;set_value('fulltext',"TRUE");<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">This "derived" field works perfectly within the abstract view.&nbsp; The definition of an Eprint containing full text or not seems to be if $eprint-&gt;get_all_documents == 0 or not.&nbsp; I expect we could create an SQL query to extract this or use
 some code.&nbsp; 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.&nbsp;
<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">We'd like to extend this virtual field a bit so that the same field can also be searched against in the advanced search.&nbsp; Has anyone implemented something along those lines?&nbsp; Or am I missing something that is maybe too obvious for me to
 see?<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">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?<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal">-Thanks,<o:p></o:p></p><p class="MsoNormal">Brian.<o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p><p class="MsoNormal"><b>Brian D. Gregg<o:p></o:p></b></p><p class="MsoNormal"><i>Solutions Architect <o:p></o:p></i></p><p class="MsoNormal">University of Pittsburgh | University Library System<o:p></o:p></p><p class="MsoNormal">Address: <a href="https://maps.google.com/maps?q=7500+Thomas+Blvd,+Pittsburgh,+PA&amp;hl=en&amp;sll=41.117935,-77.604698&amp;sspn=7.662465,13.73291&amp;oq=7500+Tho&amp;t=h&amp;hnear=7500+Thomas+Blvd,+Pittsburgh,+Pennsylvania+15208&amp;z=17" target="_blank">
7500 Thomas Blvd.&nbsp; Room 129 Pittsburgh, PA 15208</a><o:p></o:p></p><p class="MsoNormal">Tel: (412) 648-3264 | Email: <a href="mailto:bdgregg@pitt.edu">
bdgregg@pitt.edu</a> | Fax: (412) 648-3585<o:p></o:p></p><p class="MsoNormal"><a href="https://orcid.org/0000-0001-6541-4544">https://orcid.org/0000-0001-6541-4544</a><o:p></o:p></p><p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>

*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>*** Archive: <a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a><br>*** EPrints community wiki: <a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a><br>*** EPrints developers Forum: <a href="http://forum.eprints.org/">http://forum.eprints.org/</a><br></blockquote></div><br></body></html>