Class Name

atg.repository.search.refinement.FacetSearchDroplet

Component

/atg/commerce/search/refinement/CommerceFacetSearchDroplet

This servlet bean takes as input a FacetTrail object (typically as the output from the CommerceFacetTrailDroplet) and several search query attributes, constructs a search query based on these inputs, and submits the query to ATG Search. FacetSearchDroplet outputs the results returned by ATG Search as a FacetSearchResponse object, which can then be rendered on the page.

For more information about the search query attributes set by this servlet bean’s input parameters, see the ATG Search Query Reference Guide.

Input Parameters

facetTrail
The FacetTrail object returned by the CommerceFacetTrailDroplet servlet bean. Facet information in this object is used to specify constraints in the query issued to ATG Search.

pageNum
Sets the value of the pageNum attribute in the search query. This attribute specifies the page of results to retrieve from ATG Search. (0 is the first page, 1 is the second page, and so on.) If the pageNum parameter is not specified in the page, its value is taken from the component’s defaultPageNum property. The default value is 0, which means the first page is returned.

pageMode
Sets the value of the pageMode attribute in the search query. This attribute specifies what constitutes an element on the page. This has two possible values:

If the pageMode parameter is not specified in the page, its value is taken from the component’s defaultPageMode property. The default value is group, so that an individual group is not split across pages. For example, if pageSize is 10 and pageMode is group, and the result groups have a maximum size of 3, then each page will include up to 30 responses.

pageSize
Sets the value of the pageSize attribute in the search query. This attribute specifies the number of results to return per page (either individual items or groups, depending on the value of the pageMode parameter). If the pageSize parameter is not specified in the page, its value is taken from the component’s defaultPageSize property. The default value is 30.

refineMin
Sets the value of the refineMin attribute in the search query. This attribute specifies the minimum number of items that a selection value or range must have in order to be returned by ATG Search. If the refineMin parameter is not specified in the page, its value is taken from the component’s defaultRefineMin property. The default value is 1, which means that a selection range or value is returned only if it includes at least one item.

refineMax
Sets the value of the refineMax attribute in the search query. This attribute specifies the maximum number of facets (refinement elements) to be returned by ATG Search. If the refineMax parameter is not specified in the page, its value is taken from the component’s defaultRefineMax property. The default value is 5, which means that at most five facets will be returned, even if more are available.

refineTop
Sets the value of the refineTop attribute in the search query. This attribute specifies the maximum number of selection values or ranges to be returned for each facet. If the refineTop parameter is not specified in the page, its value is taken from the component’s defaultRefineTop property. The default value is 10, which means that at most ten selection values will be returned for each facet, even if more are available.

sortMode
Sets the value of the docSort attribute in the search query. This attribute specifies the criterion for sorting the result groups returned by ATG Search. If the sortMode parameter is not specified in the page, its value is taken from the component’s defaultSortMode property. The default value is relevance, which means the result groups are sorted by their relevance scores.

sortOrder
Sets the value of the docSortOrder attribute in the search query. This attribute specifies the direction of the sort. If the sortOrder parameter is not specified in the page, its value is taken from the component’s defaultSortOrder property. The default value is descending.

sortProperty
Sets the value of the docSortProp attribute in the search query. This attribute specifies the property to sort on if the value of the docSort attribute is numprop or strprop.

sortPropertyDefault
Sets the value of the docSortPropDefault attribute in the search query. This attribute provides a default value for the property specified by the docSortProp attribute.

Output Parameters

facetSearchResponse
The FacetSearchResponse object generated from the results returned by ATG Search.

errorMessage
The error message generated if an error occurs when creating the FacetSearchResponse object.

Open Parameters

output
This open parameter is rendered if no errors occur when creating the FacetSearchResponse object.

error
This open parameter is rendered if any errors occur when creating the FacetSearchResponse object.

Example

This example shows a page that uses the CommerceFacetSearchDroplet to display selection values and ranges as hyperlinks, issue search queries when these links are clicked, and display the results returned by these queries.

Note: This is a simplified example for illustrative purposes only. For a more realistic example, there are several sample JSPs in <ATG2007.3>/DAF/Search/Query/SearchTest/web-apps/search.war that use the faceted navigation servlet beans. You may find these pages helpful as starting points for writing your own JSPs.

<%@ taglib uri="dsp" prefix="dsp" %>

<dsp:page>

 <%-- Import components used in this page --%>
 <dsp:importbean
  bean="/atg/commerce/search/refinement/CommerceFacetTrailDroplet"/>
 <dsp:importbean
  bean="/atg/commerce/search/refinement/CommerceFacetSearchDroplet"/>
 <dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>
 <dsp:importbean bean="/atg/dynamo/droplet/Switch"/>
 <dsp:importbean bean="/atg/dynamo/droplet/IsNull"/>
 <dsp:importbean bean="/atg/dynamo/droplet/IsEmpty"/>
 <dsp:importbean bean="/atg/userprofiling/Profile"/>

 <%-- Output the current catalog --%>
 <dsp:valueof bean="Profile.catalog"/>

 <%-- First use the CommerceFacetTrailDroplet to get the facet trail bean.
      This servlet bean is invoked here without any input parameters, so it
      will construct the facet trail from the request's query parameters.  --%>
 <dsp:droplet name="CommerceFacetTrailDroplet">
   <dsp:oparam name="output">

     <%-- Use CommerceFacetSearchDroplet to construct the query and
          display the search results. --%>
     <dsp:droplet name="CommerceFacetSearchDroplet">

       <%-- Pass in the facet trail bean. --%>
       <dsp:param name="facetTrail" param="facetTrail"/>

       <%-- Set search query attributes. --%>
       <dsp:param name="pageNum"  value="1"/>
       <dsp:param name="pageMode" value="group"/>
       <dsp:param name="pageSize" value="10"/>
       <dsp:param name="refineMin" value="0"/>
       <dsp:param name="refineMax" value="5"/>
       <dsp:param name="refineTop" value="5"/>
       <dsp:param name="sortMode"  value="date"/>
       <dsp:param name="sortOrder" value="descending"/>

       <dsp:oparam name="error">
         Error reported by search droplet: <dsp:valueof
          param="errorMessage"/><br/>
       </dsp:oparam>

       <dsp:oparam name="empty">
         No results for this search<br/>
       </dsp:oparam>

       <dsp:oparam name="output">

         Page <dsp:valueof param="facetSearchResponse.pageNum"/> out
         of <dsp:valueof param="facetSearchResponse.totalPages"/> pages.<br/>

        <%-- Output the available facets --%>
        <h4>Available Refinements</h4>
        <dsp:droplet name="ForEach">
          <dsp:param name="array" param="facetSearchResponse.availableFacets"/>
          <dsp:setvalue param="currentFacetHolder" paramvalue="element"/>

          <dsp:oparam name="empty">
             No refinements available.<br/>
          </dsp:oparam>

          <dsp:oparam name="outputStart">
            Refine your search:<br/>
          </dsp:oparam>

          <dsp:oparam name="output">

            <%-- Put a blank line between facets --%>
            <dsp:droplet name="Switch">
              <dsp:param name="value" param="count"/>
              <dsp:oparam name="1"/>
              <dsp:oparam name="default">
                <br/><br/>
              </dsp:oparam>
            </dsp:droplet>

            <%-- Output the facet name in bold --%>
            <b><dsp:valueof param="currentFacetHolder.facet.label"/></b><br/>

            <%-- Output the selection values or ranges below the facet name --%>
            <dsp:droplet name="ForEach">
              <dsp:param name="array" param="currentFacetHolder.facetValueNodes"/>

              <%-- Get the current selection value --%>
              <dsp:setvalue param="currentFacetValueNode" paramvalue="element"/>

              <dsp:oparam name="empty">
                No values for this refinement.
              </dsp:oparam>

              <%-- Indent the child values --%>
              <dsp:oparam name="outputStart">
                <blockquote>
              </dsp:oparam>
              <dsp:oparam name="outputEnd">
                </blockquote>
              </dsp:oparam>

              <dsp:oparam name="output">

              <%-- Display selection value as a hyperlink --%>
                <dsp:getvalueof id="facetValueUrl" idtype="String"
                  bean="/OriginatingRequest.requestURI">
                  <dsp:a href="<%=facetValueUrl%>">
                    <dsp:param name="trail" param="facetTrail"/>
                    <dsp:param name="addFacet"
                      param="currentFacetValueNode.facetValue"/>
                    <dsp:valueof param="currentFacetValueNode.facetValue.value"/>
                  </dsp:a>
                </dsp:getvalueof>

                <%-- Show number of matching items --%>
                (<dsp:valueof
                  param="currentFacetValueNode.facetValue.matchingDocsCount"/>)

                <%-- Insert line break --%>
                <br/>

              </dsp:oparam> <%-- output oparam --%>
            </dsp:droplet> <%-- ForEach currentFacetHolder.facetNodeValues --%>

          </dsp:oparam> <%-- output oparam --%>
        </dsp:droplet> <%-- ForEach facetSearchResponse.availableFacets --%>

        <%-- Output details of matching products --%>
        <h4>Matching items</h4>
        <dsp:droplet name="ForEach">
          <dsp:param name="array" param="facetSearchResponse.matchingItems"/>

          <dsp:setvalue param="currentResponse" paramvalue="element"/>

          <dsp:oparam name="empty">
            No matching items
          </dsp:oparam>

          <dsp:oparam name="output">
            Response[<dsp:valueof param="index"/>] is <dsp:valueof
             param="currentResponse"/><br/>
          </dsp:oparam>
         </dsp:droplet>

       </dsp:oparam> <%-- output oparam --%>
     </dsp:droplet> <%-- CommerceFacetSearchDroplet --%>

   </dsp:oparam> <%-- output oparam --%>
 </dsp:droplet> <%-- CommerceFacetTrailDroplet --%>

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