To aid in discovery and to take advantage of rich fielded metadata, many modern search applications have some concept of faceted searching or browsing. This typically manifests itself as a list of categories into which some subset of the current search results belong.
Facet - (also called "facet field") is a field or category for which search results have one or more values. In general, this maps on to one or more indexed fields.
Facet value - is a possible value that one or more search results express in the given facet
There are no published or popular faceted search extensions for SRU or CQL, so in order to accommodate the needs of our various collections we must establish our own conventions or context sets.
Facet Request Syntax
For our first pass implementation, to meet the immediate needs of our IN Harmony collection, we must be able to convey the following information in an SRU searchRetrieveRequest along with all of the details about the search:
- the facets to calculate
- paging information for each facet (currently this only includes an optional bound on the number returned)
After receiving the information and performing the search and facet calculation, the following information must be conveyed back in the response:
- the facets that were calculated (probably mirroring all categories in the order requested)
- the facet values for each facet that had at least one hit in the search result set (constrained by the limit set in the request)
- the number of hits for each facet value in the result set
- the cql query clause that must be ANDed with the original query in order to search for the hits for the given facet value (this can simply be derived "[facetField]=[facetValue]")
- A normalized version of the requested facet parameters, to prevent the client from having to maintain that state, and to show what default paging parameters were applied by the server (in the even that they weren't specified).
In SRU/W custom extensions may be created using a limited syntax (SRU 1.2 extension information).
Because the syntax has to fit into a single URL, complex structures can't easily be encoded and we may run up against URL length limits if we're too wordy.
The maxValueCount and offset are optional paging parameters. If excluded, the server decides the paging rules which will be explicitly listed in the response.
dc.format dc.date,10, dc.subject,10,10
A request for all of the represented dc.format values, the first 10 represented dc.date values and the second page (of length 10) of the dc.subject values represented in the search results. (Sort order for paging is left up to the server, but is generally expected to be alphabetical. If sort order is a problem, the client always has the option to request all values, and handle sorting and paging at their end.
Some of the specific collection needs can't be implemented generally enough in the SRU/W server but instead must be implemented by the web application. If a reasonably general way of implementing the needed functionality can be devised, it would be ideal to move it to the SRU/W layer, but for complex cases that aren't reusable, it is a bad precedent to implement the feature in SRU/W.
The following are strong reasons to implement something at the SRU level:
- The feature is general enough that it can be defined fully and made useful for other applications.
- Required performance is unable to be accomplished from a less central location.
The following are strong reasons to implement something at the web application level:
- The feature is difficult or impossible to define in general terms.
- The feature isn't generally useful.
- The feature requires extensive, project-specific configuration to the search system
Grouping of 5 year periods in a copyright date facet.
The web application should request all facet information for copyright date (this will rarely be even 100s of searches and shouldn't kill performance) and then consolidate by half-decade, creating queries by ORing the query fragments for each result.
Knowing when to display a button to request all facets (ie, knowing when there are more, undisplayed results)
The web application should request x + 1 facets for each field where x is the number to display. The (x + 1)th result shouldn't be displayed, but if it's present, a button should exist saying "Display all".