Coding Advanced Search Pages

EPA builds all web content in the Drupal WebCMS as of January 2013. All new microsites and resource directories will be created using Drupal.  There is still content on EPA's legacy servers and this content will be maintained there until it is transformed and moved into the Drupal WebCMS.  The following information should be used only for minor updates/maintenance of existing pages; any significant updates or revisions to existing pages should be done in the context of One EPA Web content transformation into the Drupal WebCMS.

OEI will provide basic filtered search capabilities for Drupal WebCMS that do no require the author to code their own search form.  Instructions for specialized, dedicated search pages on Drupal WebCMS will be provided shortly.

 

An advanced search page enables a user to perform more advanced searches than with standard search. It offers all of the options of standard search, plus:

  • the ability to search within specific fields, such as title, keywords or description
  • the ability to search using Boolean operators

NOTE: A program or region would typically have a simple search box on all of their HTML pages, but only one or a few advanced search pages. If you have an advanced search page for your area, you should add the areasearchurl parameter to all of your basic search pages, so that the "Advanced Search" link in the search results will point to your advanced search page.

On this page:

Top of Page


Builld an Advanced Search Form

The easiest way to build an advanced search page for your area is to copy the public access or intranet advanced search page:

http://www.epa.gov/epahome/search.html

http://intranet.epa.gov/agcyintr/search.html

and add the filter, fld and areaname parameters for your area (see " Create a Web Area Search Form").

Top of Page

Fields available to advanced search

Field name Notes
audience For future expansion – the intended audience for this page
author Populated from author metatag
epa_collection "metaboth" or "all". Metaboth indicates document is in WEBI or iWEBI.
epa_group Populated from "group" metatag
epa_title Untruncated preferred title
homepage 1 if designated as homepage in WEBI, otherwise blank or 0
keyword Keywords from metatags + WEBI keywords if found
metacoll For future use
object-type Full MIME-Type of document
rating WEBI page rating
searchfirst Composite field used internally
searchsecond Composite field used internally
textw Words anywhere in the document
tssms Account code for document
url Preferred URL

Top of Page

Coding the advanced search form

Advanced search is implemented as a separate servlet in the epasearch webapp. For public access, the action parameter of your form should point to http://nlquery.epa.gov/epasearch/advanced. For intranet, the URL is http://nlintrasearch.epa.gov/epasearch/advanced.

All of the parameters and rules for basic search apply to advanced search with one exception – there is no querytext parameter. Instead, query text is specified using four pairs of parameters. The first of each pair is a text box into which the user types his search terms. The second of each pair is the name of the field to search in. This is typically implemented using a dropdown.

In most cases, you should provide a textbox of each of the four text fields, each paired with a dropdown for selecting the field to search. The default fieldname is textw (fulltext).

Text field Operator Fieldname field
anyquery Any of these terms anyin
allquery All of these terms allin
nonequery None of these terms nonein
phrasequery Exact phrase phrasein
Sample 1. – Region 13 advanced search on public access.
<form method="get" action=http://nlquery.epa.gov/ epasearch/epasearch>
<input type="hidden" name="typeofsearch" value="area">
<input type="hidden" name="areaname" value="Region 13">
<input type="hidden" name="filter" value="samplefilt.hts">
<input type="hidden" name="fld" value="region13">
<input type="hidden" name="result_template" value="epafiles_defaults.xsl">
Any of these words: <input name="anyquery" value="" size="30" />
<select name="anyin">
  <option value="textw" selected= "selected">anywhere in the document</option>
  <option value="title">in the title< /option>
  <option value="keywords">in the keywords</option>
  <option value="description">in the description</option>
  <option value="url">in the url </option>
</select>
<input type="submit" value="Go">
<input type="reset" value="Reset">
All of these words: <input name="allquery" value="" size="30" />
<select name="allin">
  <option value="textw" selected="selected">anywhere in the document< /option>
  <option value="title">in the title</option>
  <option value="keywords">in the keywords</option>
  <option value="description">in the description</option>
  <option value="url">in the url< /option>
</select>
None of these words: <input name="nonequery" value="" size="30" />
<select name="nonein">
  <option value="textw" selected=" selected">anywhere in the document</option>
  <option value="title">in the title</option>
  <option value="keywords">in the keywords</option>
  <option value="description">in the description</option>
  <option value="url">in the url< /option>
</select>
This exact phrase: <input name="phrasequery" value="" size="30" />
<select name="phrasein">
  <option value="textw" selected="selected">anywhere in the document< /option>
   <option value="title">in the title</option>
   <option value="keywords">in the keywords</option>
   <option value="description"> in the description</option>
   <option value="url">in the url</option>
</select>
Document type:
<input type="checkbox" name="doctype" value="html" checked="checked" />HTML
<input type="checkbox" name="doctype" value="pdf" checked="checked" />PDF
<input type="checkbox" name="doctype" value="plain" checked="checked" />Text
<input type="checkbox" name="doctype" value="msword" checked="checked" />Word
Sort by:
<input type="radio" name="sort" value="term_relevancy" checked="checked" />Relevance
<input type="radio" name="sort" value="date" />Date
</form>

Top of Page