14. How to Make Complex Boolean Searches Using "Field Groups"


Some forms can have Input boxes organized in groups so that you can perform a query using a predefined hierarchy of Boolean operators, likewise using parentheses.
For more information see the document on Boolean Operators and freeWAIS-sf
Because of how the Boolean operators are managed by SFgate, (see also How to Perform Serach in More Than a Field), it is always better to restrict each group at no more than 2 fields like in the examples below.

In the following example

Fields Group 1
Fields Group 2

the query will be processed this way:

(Title="Alport" or Investigator="Salviati" ) AND (Financial Support > 100 and Financial Support < 200 )


Here you can inspect the .fmt file, while the relevant parts of this form source code is here:

<FORM METHOD=POST ACTION="/htbin/SFgate">
<INPUT NAME="database" TYPE="hidden" VALUE="local//usr/local/wais-sources/telethon/telethon">

<CENTER>
<TABLE BORDER WIDTH=70%>
    <TR><TH> </TH><TH>
    <TABLE WIDTH="100%">             
     <TR><TH COLSPAN=3 align=left><FONT SIZE="+2">Fields Group 1</FONT></TH></TR>
         <TR><TD><SELECT NAME="fieldsel_1_description">
             <OPTION SELECTED>Title of the Project
             <OPTION>Investigator
             <OPTION>Department
             <OPTION>City
             <OPTION>Classification of the Project
             <OPTION>Grant
         </SELECT></TD>
             <TD><INPUT TYPE="text" NAME="fieldsel_1_content" VALUE="alport" SIZE=40></TD>
                 <TD><SELECT NAME="fieldsel_1_tie">
                     <OPTION>and
                     <OPTION SELECTED>or
                     </SELECT>
                     </TD></TR>

         <TR><TD><SELECT NAME="fieldsel_2_description">
              <OPTION>Title of the Project
              <OPTION SELECTED>Investigator
              <OPTION>Department
              <OPTION>City
              <OPTION>Classification of the Project
              <OPTION>Grant
         </SELECT></TD>
             <TD WIDTH=50%><INPUT TYPE="text" NAME="fieldsel_2_content" VALUE="salviati" SIZE=40></TD></TR>
    </TABLE>   

<TR><TD>
    <SELECT NAME="group_2_tie">
            <OPTION>and
            <OPTION>or
    </SELECT>
</TD></TR>
<TR><TH> </TH><TH>
    <TABLE ALIGN=left>             
     <TR><TH COLSPAN=4 align=left><FONT SIZE=+2>Fields Group 2</FONT></TH></TR>

         <TR><TD><SELECT NAME="fieldsel_3_description">
               <OPTION>Time Extension
               <OPTION>Renewals
               <OPTION SELECTED>Financial Support
         </SELECT></TD>

         <TD><SELECT NAME="fieldsel_3_p">
               <OPTION SELECTED> &gt;
               <OPTION> &gt;=
               <OPTION> ==
               <OPTION> &lt;=
               <OPTION> &lt;
               </SELECT></TD>

             <TD><INPUT TYPE="text" NAME="fieldsel_3_content" VALUE="100" SIZE=3 MAXLENGHT=3></TD>

             <TD><SELECT NAME="fieldsel_3_tie">
                <OPTION>and
                <OPTION>or
             </SELECT></TD>


             <TD><SELECT NAME="fieldsel_4_description">
                <OPTION>Time Extension
                <OPTION>Renewals
                <OPTION SELECTED>Financial Support 
             </SELECT></TD>

             <TD><SELECT NAME="fieldsel_4_p">
                <OPTION> &gt;
                <OPTION> &gt;=
                <OPTION> ==
                <OPTION> &lt;=
                <OPTION SELECTED> &lt;
                </SELECT></TD>

            <TD COLSPAN=2><INPUT TYPE="text" NAME="fieldsel_4_content" VALUE="200" SIZE=3 MAXLENGHT=3></TD></TR>
  </TABLE>
 </TH></TR>
</TABLE>   
</CENTER>

<INPUT TYPE="hidden" NAME="fieldsel_name_title" VALUE="Title of the Project">
<INPUT TYPE="hidden" NAME="fieldsel_name_investigator" VALUE="Investigator">
<INPUT TYPE="hidden" NAME="fieldsel_name_department" VALUE="Department">
<INPUT TYPE="hidden" NAME="fieldsel_name_city" VALUE="City">
<INPUT TYPE="hidden" NAME="fieldsel_name_classification" VALUE="Classification of the Project">
<INPUT TYPE="hidden" NAME="fieldsel_name_grant" VALUE="Grant">
<INPUT TYPE="hidden" NAME="fieldsel_name_time-ext" VALUE="Time Extension">
<INPUT TYPE="hidden" NAME="fieldsel_name_renewals" VALUE="Renewals">
<INPUT TYPE="hidden" NAME="fieldsel_name_amount" VALUE="Financial Support">

<INPUT TYPE="hidden" NAME="group_1" VALUE="fieldsel_1, fieldsel_2">
<INPUT TYPE="hidden" NAME="group_2" VALUE="fieldsel_3, fieldsel_4">

<CENTER>
<TABLE>
<TR>
<TH><INPUT TYPE="submit" VALUE="Start Search">
</TH><TH> </TH><TH>
<INPUT TYPE="reset"  VALUE="Reset Query"></TH></TR>
</TABLE>
</CENTER>

<P>

<INPUT TYPE="hidden" NAME="tieinternal" VALUE="and">
<INPUT TYPE="hidden" NAME="application" VALUE="projects">
<INPUT TYPE="hidden" NAME="convert" VALUE="Table">
<INPUT TYPE="hidden" NAME="listenv" VALUE="table">
<INPUT TYPE="hidden" NAME="range" VALUE="1">
</FORM>

The important parts of this form are:
  1. Definition of description name for fields and their grouping.

    <INPUT TYPE="hidden" NAME="fieldsel_name_title" VALUE="Title of the Project">
    <INPUT TYPE="hidden" NAME="fieldsel_name_investigator" VALUE="Investigator">
    <INPUT TYPE="hidden" NAME="fieldsel_name_department" VALUE="Department">
    <INPUT TYPE="hidden" NAME="fieldsel_name_city" VALUE="City">
    <INPUT TYPE="hidden" NAME="fieldsel_name_classification" VALUE="Classification of the Project">
    <INPUT TYPE="hidden" NAME="fieldsel_name_grant" VALUE="Grant">
    <INPUT TYPE="hidden" NAME="fieldsel_name_time-ext" VALUE="Time Extension">
    <INPUT TYPE="hidden" NAME="fieldsel_name_renewals" VALUE="Renewals">
    <INPUT TYPE="hidden" NAME="fieldsel_name_amount" VALUE="Financial Support">
    
    <INPUT TYPE="hidden" NAME="group_1" VALUE="fieldsel_1, fieldsel_2">
    <INPUT TYPE="hidden" NAME="group_2" VALUE="fieldsel_3, fieldsel_4">
    
    
  2. Correct coding of the fieldsel_tie For a correct interpretation of the query fieldsel_tie must refer to the first fieldsel_description inside each group.
    If a group contains more than two fieldsel_description only experts users can perform correct queries. So we prefer to restrict groups to no more than two fieldsel_description.

  3. Correct coding of the group_tie For a correct interpretation of the query group_tie must refer to the next group.



THIS PAGE REFERENCES:
© 1996-97 BioPD - University of Padova - Author: Leopoldo Saggin
Mail to: lsaggin@civ.bio.unipd.it - Last Revision: August 21, 1997
Tested on Netscape 1.22 and higher