Background

For a presentation about AJAX I have modified DSpace 1.3 so all search fields have autosuggest capability like Google suggest (http://www.google.com/webhp?complete=1&hl=en)

What it does

When the user starts to type in a search field (excluding advance search) a list of suggestions is displayed beneath the search field. This list contains the number of hits for the current collection and the number of hits and suggestions for a specific index, for example the author or title index. The user can select an item from this dropdown list to immediately search for that term in that index.

How it works

Via Javascript an event handler for the keydown event is attached to all input fields with name 'query'. When something is typed in such an input field multiple AJAX http request are sent asynchronously to dspace. An AjaxSearchServlet handles those request and sends results back using JSON. Via javascript these results are displayed using the DOM in a dropdown list.
Which indexes are used and how many results are displayed is configurable.

Which DSpace version

The modifications I made were made to Dspace 1.3.2, but it should work with no extra work in another version of Dspace, or with Manakin.

How to install

It is relatively easy and non-invasive to install. Some files must be added and some changes to configuration must be made

Step 1: Adding AjaxSearchServlet

  <servlet>
    <servlet-name>ajax-search</servlet-name>
    <servlet-class>org.dspace.app.webui.servlet.AjaxSearchServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>ajax-search</servlet-name>
    <url-pattern>/ajax-search</url-pattern>
  </servlet-mapping>

Step 2: Adding Javascript

  <script type="text/javascript" src="<%= request.getContextPath() %>/ajax/ajax.js"></script>
  <script type="text/javascript" src="<%= request.getContextPath() %>/ajax/autosuggest_search.js.jsp"></script>

Step 3: Configuring

  ajax.autosuggest.index.1 = author
  ajax.autosuggest.index.2 = title
  ajax.autosuggest.index.3 = keyword
  ajax.autosuggest.pagesize = 100
  ajax.autosuggest.itemcount = 5

The first 3 lines indicate which indexes to search. You can add more indexes, or delete some indexes if you want. Be carefull that the numbering stays good. And that the indexes are configured with the same name, see the search.index.n keys of dspace.cfg

The ajax.autosuggest.pagesize key gives the maximum number of hits. If more are found than >99 is displayed instead of the actual number. If this is 0 (zero) or missing then no list of suggestions is displayed, affectively disabling 'Autosuggest+using+AJAX'.

The ajax.autosuggest.itemcount key gives the maximum number of suggestions for each index. If this is 0 (zero) or missing no suggestions are displayed.

  jsp.ajax.types.author = authors
  jsp.ajax.types.title = titles
  jsp.ajax.types.keyword = keywords

These are the translations for the names of the indexes.

Step 4: build / install / restart

Do the stuff you normally do when deploying a new version of DSpace.

Contact me

If you need help, or have any comments, or you just want to inform me that you (are going to) use this, please contact me.

See inside the source files for my e-mail.