Analytics & Reports
Analytics

Search

Here you can set search page specific configurations. These configurations are going to impact how the product grid renders.

Property Type Default
fields string[] properties in structure
maxRefinements number 20
pageSize [ValueOptions]<number> 10
sort [ValueOptions]<{ field: string, descending: boolean }>
redirectSingleResult boolean false
overrides Object or Function that returns an Object
useDefaultCollection boolean false

fields

Specify which fields should be returned on each record that comes back from the engine. You may specify more than one field, if you specify * all fields will be returned. If this parameter is blank, the search service will return an error. If this parameter is omitted, the search service will return only the title field. The title field is always returned. You can exclude fields from being returned using -. Exclusion will take precedence over inclusion.

These are then available for the tile components or other logic within your application.

maxRefinements

The maximum number of refinements within a specific navigation that will be shown by default. Note that the search API itself has a limit of 20 refinements, so if no maxRefinements is supplied then this limit of 20 will be used, and setting a maxRefinements greater than 20 will have no effect.

This does not affect the behavior of the more refinements button.

pageSize

The page size indicating the number of records to return per page. The search engine limits the number of results per page to 120, setting this to a higher number will still return 120 products per page. For example:

search: {
  pageSize: { options: [30, 60, 90, 120], default: 30 }
}

sort

The sort options that can be applied to the results. A matching set of labels needs to be defined under Tags. Sample configuration for search:

search: {
  sort: {
   options: [
    { field: '_relevance', descending: true },
    ...(loggedin ? [
       { field: 'product_price', descending: false }
       { field: 'product_price', descending: true },
     ] : []),
    { field: 'item.rating', descending: true },
    { field: 'title', descending: false },
    { field: 'title', descending: true },
  ]
 }
}

redirectSingleResult

The boolean to control if page will be redirected when there is only one search result

overrides

You can add overrides to the Search calls for the pages. Any Search API supported functions can be used here. This can be used as an object, e.g.:

search: {
   overrides: {
       customUrlParam: [{key: "my-key", value: "my-value"}],
       refinements: [{type: "Value", navigationName: "Example_Name", exclude: true, value: "Example"}]
 }
}

… or you can use a function that returns an object - allowing you to customize the override from other portions of the application. For example:

search: {
  overrides: (req) => {
    // do stuff with my request, e.g. figure out what my custom parameters are
    return {
      customUrlParam: [{ key: 'my-key', value: 'my-value' }],
      refinements: [{ type: 'Value', navigationName: 'Example_Name', exclude: true, value: 'Example' }]
    }
  }
}

useDefaultCollection

Whether to always use the default collection when performing a search.

  • true: use the default collection on search.
  • false: use the current collection on search.