You issue faceted search queries with the QueryFormHandler, which takes the FacetTrail object and various ATG Search query attributes and constructs a search query that specifies:

The QueryFormHandler submits the search request to ATG Search and receives back a search response. The FacetSearchTools class handles the processing of the search request by creating constraints and specifying the refinement configuration to use, based on the entries in the facet trail. FacetSearchTools also processes the search response by converting the Refinements object into an array of facets that can be manipulated individually. The page developer can then use servlet beans or JSP tags to iterate through the response and display the resulting facets and selections and the products returned. The selection ranges or values can be displayed as hyperlinks which, when clicked, pass the new facet trail string and modification instructions as query parameters to the linked page.

To configure the request and response processing, you add a component of class FacetSearchTools to the QueryFormHandler component’s searchRequestProcessors and searchResponseProcessors array properties. For example:

searchRequestProcessor+=/atg/search/repository/FacetSearchTools
searchResponseProcessor+=/atg/search/repository/FacetSearchTools

Note that the /atg/commerce/search/catalog/QueryFormHandler component is preconfigured to use /atg/search/repository/FacetSearchTools.

The following example creates a search form where a user can enter text and then click a button to submit the query. The results are returned as a QueryRequest.Response object (stored in the QueryRequest.searchResponse property). The FacetSearchTools component converts the raw facet data (found in the Refinements object stored in the QueryFormHandler.searchResponse.refinements property) and stores the converted data in the FacetSearchTools.facet property for use on the page.

<dsp:form id="searchForm" name="searchForm" formid="searchForm"
             method="post" action="simpleFacet.jsp">

  <!-- the text field is linked to the searchRequest's question property -->
  <p>question:  <dsp:input type="text" id="question" size="60"
                  name="question" bean="QueryFormHandler.searchRequest.question"/>

  <!-- submit button invokes the handleSearch method on the QueryFormHandler  -->
  <p><dsp:input type="submit" bean="QueryFormHandler.search" value="Search"/>

  <!-- get the search response, facets, and facet trail string    -->
  <!-- from the initial request                                   -->
  <dsp:getvalueof bean="QueryFormHandler.searchResponse"
     var="queryResponse" scope="request"/>
  <dsp:getvalueof bean="FacetSearchTools.facets" var="facetHolders"
     scope="request"/>
  <dsp:getvalueof param="trail" var="trailString"/>

. . .
</dsp:form>
 
loading table of contents...