Skip to the content Back to Top

Andornot has long recommend using canned queries into your databases as a means of surfacing information for users. On a web-accessible database, a canned query takes the form of a URL with some search terms in it that retrieve records from the database with a single click. Common uses are to retrieve:

  • new items added to a database, such as the latest books catalogued in a library, or latest legal memos in a law firm database;
  • items on a particular subject in a library catalogue, or a finding aid for a particular archival fonds;
  • a list of all journals, maps, DVDs, etc. in a library catalogue.

By constructing the search for the user, we can guide them towards new, interesting or relevant resources in a collection, and help new users in particular to quickly and easily see what the database contains. From there, users can begin their own searching, knowing what sort of information and keywords to use.

Andornot provides a web-based Search Cannery Wizard to help you construct URLs that will search your database. By filling in fields on this form, you can create a URL such as the following, which searches the sample library catalogue database included in our Andornot Starter Kit for all the journals:

http://ask.andornot.com/results.aspx?BU=/&TN=starter&QY=find%20%28MaterialType%20%3DJournal%29&RF=WebBrief&DF=WebFull&MR=10&NP=255&RL=0&DL=0&XC=&ID=&AC=QBE_QUERY

This is a very useful URL to be able to give a user. This one in particular can be given to new staff to ask which titles they’d like routed to them. There are just a couple potential problems with the URL:

1. It’s long and in some email clients, the text will wrap to a second line and the link will be broken.

2. The URL isn’t easily read to decipher what it might lead to (unlike, say, www.andornot.com, which can be predicted to lead to our website).

URL Rewriting

A great solution to these two issues is to use a technique known as URL rewriting to replace the lengthy URL with a shorter, friendlier one, such as http://ask.andornot.com/permalink/journals

This short URL is easily read and can be predicted to lead to a list of journals in the starter kit sample database.

A short URL like this can be emailed to colleagues or published on an intranet. When the web server receives a request for this “page” in the website, it translates it into the longer URL that performs the canned query. This all happens behind the scenes, so while the user immediately sees the list of journals, only the friendly URL remains in their browser address bar.

The permalink portion of the URL is a common term used to indicate that the URL will be around for a while and the user can reliably bookmark it. Though it’s not strictly necessary, it helps to differentiate these types of URLs from ones that correspond to folders in the website.

URL rewriting is also a great technique for linking to specific records in a database. For example, this short URL http://ask.andornot.com/permalink/67/Architectural Record leads to the catalogue record for the Architectural Record journal. The link can be generated using the unique ID or number that every record in a database should have, and a rewrite rule that translates it into a search.

Real-World Examples

The Law Society of Saskatchewan Library has a series of short, friendly URLs set up to retrieve the latest works from their catalogue in different legal practice areas. The URLs also correspond to the RSS feeds set up in the same way. Both provide a means for lawyers to stay abreast of new items of interest to them, whether by bookmarking a short URL, or by subscribing to the RSS feed.

Here are a few examples:

http://lss.andornot.com/opac/permalink/commercial-law

http://lss.andornot.com/opac/permalink/environmental-law

http://lss.andornot.com/opac/permalink/family-law

More are listed on this page, along with the RSS feeds (which are described in detail in this blog post).

The Provincial Resource Centre for the Visually Impaired (PRCVI) runs most of their website content from an Inmagic database (we blogged about this here). We recently replaced lengthy canned query URLs with short, friendly ones, such as:

http://www.prcvi.org/NewsEvents

http://www.prcvi.org/LearningCentre

http://www.prcvi.org/SpecialInterest

These URLs are easily emailed to the students and teachers that PRCVI serves, yet always retrieve the latest information from their database.

Detailed instructions for setting up URL rewriting is provided below for DIY types who like to roll up their sleeves and get hands-on with their server. If you’d like our assistance, please contact us – we’d be happy to help you take advantage of this simple technique to improve service to your users.

 

URL Rewriting – How To Do It

diyCaution: technical jargon ahead!

URL rewriting can be set up in IIS, the Microsoft web server, quite easily. In IIS 7, for example, you would download and install the URL Rewriting module from Microsoft, if it’s not already installed, then set up rewrite rules such as this one:

<rewrite>

<rules>

<rule name="Journals">

<match url="^permalink/journals" />

<conditions logicalGrouping="MatchAll" />

<action type="Rewrite" url="/results.aspx?AC=qbe_query&amp;TN=starter&amp;RF=WebBrief&amp;DF=WebFull&amp;DL=0&amp;RL=0&amp;NP=255&amp;MR=10&amp;QY=find+MaterialType+=Journal" />

</rule>

</rules>

</rewrite>

As you can see, this rule takes an incoming URL that matches this

^permalink/journals

and translates it to this

/results.aspx?AC=qbe_query&amp;TN=starter&amp;RF=WebBrief&amp;DF=WebFull&amp;DL=0&amp;RL=0&amp;NP=255&amp;MR=10&amp;QY=find+MaterialType+=Journal

which is a canned query into a sample database that finds all records which are journals.

Note that you could still use the Andornot Search Cannery Wizard to construct this URL.

Here’s one that can take a URL that includes a unique record ID and a title, such as http://ask.andornot.com/permalink/67/Architectural Record and translate it into a search for a specific record in the database, using a regular expression (RegEx), to parse the ID and title from the URL .

<rule name="Permalink">

<match url="^permalink/([0-9]+)/(.*)" />

<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

<action type="Rewrite" url="/results.aspx?AC=qbe_query&amp;TN=starter&amp;RF=WebFullPURL&amp;DF=WebFullPURL&amp;DL=0&amp;RL=0&amp;NP=255&amp;MR=10&amp;QY=find+RecordId+%3d{R:1}" />

</rule>

In the above, the title is discarded and the unique record ID is used as a parameter in a search.

Rewrite rules can be added through the IIS management console GUI, or simply by editing your web application’s web.config.

You can learn more about the IIS 7 URL Rewrite module and download it here.

In IIS 6, we recommend using the open-source URL rewriting module available from http://www.urlrewriting.net. Instructions are provided for installing and configuring the module and making appropriate entries in your web application’s web.config file. Once installed, rules similar to those shown above for IIS 7 may be used. For example, this rule can be used to link to a specific record in a database.

<urlrewritingnet defaultPage = "default.aspx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >

<rewrites>

<add name="Permalink" virtualUrl="^~/permalink/([0-9]+)/?default.aspx"

rewriteUrlParameter="ExcludeFromClientQueryString"

destinationUrl="~/results.aspx?AC=qbe_query&amp;TN=starter&amp;RF=WebFull&amp;DF=WebFull&amp;MF=GENERICWPEngMsg.ini&amp;NP=255&amp;RL=0&amp;DL=0&amp;CS=0&amp;QY=find%20RecordID%20%3d$1"

ignoreCase="true" />

</rewrites>

</urlrewritingnet>

Other Rewrite Rules

In addition to rewrite rules to link to a specific record and to replace long canned query URLs, we recommend that you set up two more additional rules, to add or remove trailing slashes, and to convert all URLs to lower case.

To a human and a web server, http://ask.andornot.com/permalink/67/ArchitecturalRecord and http://ask.andornot.com/permalink/67/ArchitecturalRecord/ are similar, but to a search engine, they are quite different. It's a good idea to set up a rule to consistently add or remove the trailing slash, to improve search engine ranking.

The same applies to mixed upper and lower case in URLs – it’s a good idea to enforce all lower case so that the page appears as one to a search engine. Examples of these rules may be found here: http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx

Categories

Let Us Help You!

We're Librarians - We Love to Help People