Personal tools
University Computing Service

University Search Service

Setting up search boxes

Introduction

The search service at search.cam.ac.uk (and the 'old' service at web-search.cam.ac.uk) can be used to search University-wide or to search specific servers (or parts of servers). It can therefore be used by webmasters around the University to provide a search facility for their servers or for specific collections of information on their servers without the need to run search software locally, assuming that the servers are being indexed for searching and that the scope of the indexing and the available search facilities meet their needs. If you are unsure whether your web content is being indexed, email web-support@ucs.cam.ac.uk telling us the URLs of the web content concerned.

The search service at search.cam.ac.uk will search the whole University index. The 'new' search service varies from the 'old' search (at web-search.cam.ac.uk) in two respects:

  • authorised users are now able to set up filtered searches (equivalent to packaged searches in the 'old' search) themselves. Previously you needed to ask webmaster to set up such services.
  • the new search constraints added are in a different form and are not cross-compatible with those used in the old search. The 'old' search constraints were added by using a value 'qp' - the new search constraints are for institution (name="inst") and a search tag (name="tag") that refers to a list of urls that should be searched.

The pages that access the functionality for adding search filters for your institution may be found by following the 'Administer Search' link in the top right of the search interface screen (http://search.cam.ac.uk/), which you will see if you already have editing rights for the Lookup "Editors Group" for your institution. If you don't see this link, you have three choices:

  • get these editing rights
  • ask a person who has editing rights to set up a search tag for you
  • use dynamic search filters instead of assigning the search to your institution

To find your local contact, go to Lookup, search for your institution, go to the 'Groups' tab, and select "Editors group for 'your institution'", where you will see a contact name and link to details. You can request to join this group by sending email to this contact, explaining why you need to join or asking them to set up the search tag for you. If you are running a web server that is not part of the institution to which you belong, contact search-support@ucs.cam.ac.uk with details, and we'll try to help.

Defining what is searched using the new search interface

Once you have editing rights and you follow the 'Administer Search' link, you will see the following screen (but showing your institution where the arrow indicates rather than "University Computing Service"):

Admin page for search interface

If you follow the link (or links) to view or edit search filters, you will see a screen for "Website Search Filters", containing any existing filters you had in the old system and below these a button "Add a new search filter".

Editing existing filters

The existing filters from the 'old' search (http://ext.web-search.cam.ac.uk/ucamservers.html) have been partly imported into the new, but some will need completing before they can be used. When constructing search boxes, a filter is identified by an institution and a search tag. You must supply a search tag for a filter in order to use it in this manner. In some cases tags will have been derived from the old packaged searches; you can use these or invent your own. When you look at the existing filters your institution has you'll see a filter labelled '(main institution website)'. This filter alone does not need a tag (but you may add one if you wish) but you should edit any other filters to add an appropriate tag, and then they will be ready to use.

Adding a new filter

When you add a new filter you will see a screen like the following, into which you must add four pieces of information:

Adding a new search filter

  • Main filter: Whether this filter is to be the main one for the institution
  • Title: The title of the filter (which may be left blank for the institutional filter)
  • Search Tag: The search tag, which is the key you want to use for a search of a group of web locations
  • Search URLs: Search URLs, which are the web locations you want searched

An example of a completed filter is shown here:

An example filter

Once the filter has been completed and saved, you will see a page that gives you worked examples of how to use it. For the filter shown above, this page looks as follows:

Filter and examples code of how to use it

The suggested code can be copied and pasted into your page. To change the text on the search button, alter the text in value="". There are some additional attributes that should be added for accessibility purposes - the 'label' attribute ties the label to the appropriate input, and the accesskey value allows people using the University templates and a speaking browser easy access to search. With these additions, the above example looks like this:

<form method="get" action="http://search.cam.ac.uk/web"><p>
<label for="query">Enter your search</label> 
<input type="submit" id="query" accesskey="4" value="Search Computing Service 
     documentation" />
<input type="hidden name="inst" value ="CS" />
<input type="hidden name="tag" value ="docs" />
</p></form>

When this search is used the results come back with the following heading:

Results from a filtered search

When you have added a new filter, if you would like it added to the 'old' search interface, you will need to tell us about it by emailing web-support@ucs.cam.ac.uk.

Dynamic search filters

There are some cases where it is impractical to manually create a search filter in our system for every filtered search you want to do.  Examples include: limiting the search to specific issues of the reporter, or to the pages of individual users. We have developed an alternative mechanism for these situations.

To perform a dynamic filtered search, use the following parameters in your URL:

filterTitle - A short title describing what is being searched (displayed on the results page)
include - A URL to include  (may be repeated)
exclude - A URL to exclude (may be repeated)

filterTitle is required, and at least one include or exclude is required.  A search result will only be displayed if it matches one or more include URLs, and does not match any exclude URL.

An example would be:

<form method="get" action="http://search.cam.ac.uk/web"><p>
Enter your search: <input type="text" name="query" />
then select <input type="submit" value="Search 2008-9 Special Reporter" />
<input type="hidden" name="filterTitle" value="Reporter special issues 2008-09" />
<input type="hidden" name="include" value="http://www.admin.cam.ac.uk/reporter/2008-09/special" />
</p></form>

You can try that here:

Enter your search: then select

A search box including radio button alternatives

While it was straightforward in the 'old' search to set up a search box with alternate radio buttons, in the new search interface this may only be done programmatically. If you need to use this functionality, please ask for further advice.

Notes about html encoding

When characters that have special meaning in HTML (in particular, "<", "&", and ">") are needed as normal text they must be encoded as HTML named or numeric character entities. This might arise in the value given in <input name="filterTitle" type="hidden" value="Staff & students" />, as that piece of text is used as the heading on the search results page.

Comments and questions about the topics covered in this document can be sent to web-support@ucs.cam.ac.uk

Last updated: January 2012