Skip to main content

Overview

caution

This page is under construction. Some sections may be incomplete or missing.

The Search Config (/search.config.ts) is an object-like interface for defining search parameters. The facets, listings, and minilist objects provide the configurations for their respective hooks; useFacets, useListing, and useMinilist.

Every search object follows the same pattern and full TypeScript support is available.

Search Config

NameTypeFormatDescription
tabsobject[]TabAn array of tabs
facetsobject{ [key]: Facet }An object with a key for each facet that is required for the search
listingsobject{ [key]: Facet }An object with a key for each independent listing that is required for the site
minilistobject{ [key]: Facet }An object with a key for each independently identifiable minilist that is required for the site

Tab

NameTypeFormatDescription
idnumberThe zero-based incrementing id assigned to the tab
labelstringThe tab's label for rendering
defaultFacetstringThe initially displayed facet (if not the first specified)
totalCountstring[]Facet[key][]The facets which make up the tab's total results (useful if you do not want a mixed-results facet to interfere with the total, or if you only want to count the mixed-results facet results and not facets which are a filtered set of another facet's results)

Facet

NameTypeFormatDescription
[key]stringkey-safe-no-spacesThe facet key used to identify the facet
isDefaultbooloptionalThe first facet to be shown if no facet is supplied via a route parameter
isDisabledbooloptionalSet to true to temporarily disable the facet
tabIdnumberUse 0 for default or the id assigned to the tab
title
projectIdstringoptionalUse this to target the search to a project other than the default configured
queryParamsobjectQueryParamsQuery params object to drive the search for this facet
filtersobject{ [key]: Filter }An object with a key for each filter that is required in this facet

QueryParams

NameTypeFormatDescription
contentTypeIdsstring[]An array of contentTypeIds to search over (sys.dataFormat == 'entry'); Prefix an entry with a "!" to exclude that content type from the search
assetTypesstring[]optionalAn array of assetTypes to search over (sys.dataFormat == 'asset'); Prefix an entry with a "!" to exclude that content type from the search
webpageTemplatesstring[]optionalAn array of webpageTemplates to search over (sys.dataFormat == 'webpage'); Prefix an entry with a "!" to exclude that webpage template from the search
fieldsstring[]An array of fields to return for each entry in the items[]
linkDepthnumberoptionalThe linkDepth to apply to the facet search (defaults to 0)
featuredResultsobjectFeaturedResultsAn object containing the configuration to drive fetching featured search results separately from the main search results
includeInSearchstring[]optionalAn array of field ids relating to boolean field types in the destination content types to control whether or not the entry can be shown in search results
loadMorePagingbooleanoptionalInclude this parameter to change the pagination behaviour of your search. Load more paging will retain previously fetched search results, appending additional pages of results to the existing results array, rather than replacing the results[] when switching pages normally
orderBystring[]An array of orderBy expressions to add to the search query
pageSizenumberThe number of items returned per page in the search
useSearchTermbooleanoptionalAllow a configured minilist to read the search.term set in state (default is false) works with minilists only
weightedSearchFieldsobject[]WeightedSearchField[]An array of WeightedSearchField to include in the search query. If you do not include this configuration, your search term will be queries against a default set of fields that exist in every content type. It is recommended to specify weightedSearchFields for each contentTypeId specified in your queryParams so you can search for terms that exist within custom entry fields and weight the results returned from each field according to their relevance. The default fields include entryTitle, entryDescription, keywords, sys.uri and searchContent (available in Contensis v14+ only)
customWhereobject[]CustomWhereClause[]An array of CustomWhereClause to include in the search query

FeaturedResults

NameTypeFormatDescription
fieldIdstring / string[]optionalThe field we are looking for to distinguish the featured resuls from regular search results. It is possible to provide an array of fieldIds to wrap multiple field expressions inside an or operator.
fieldValueanyoptionalThe value for the field we are looking for to distinguish the featured resuls from regular search results
contentTypeIdstring / string[]optionalInstead of using a field to distinguish the featured results from regular search results we can get results that exist inside a special content type containing featured search results in entry data.
countnumberThe number of featured results to return (and exclude from the main search results)

WeightedSearchField

NameTypeFormatDescription
fieldIdstring / string[]The field we are applying the weighted search term to. It is possible to provide an array of fieldIds to wrap the weighted search expression inside an or operator.
weightnumberThe weight value we are supplying to the Delivery API to rank the search results

CustomWhereClause

N.B. This shares syntax with adding where operators to a search query when using the Delivery API via HTTP, and should be used sparingly for exceptional cases where the standard query falls short. We can also wrap clauses in not, and, and or expressions.

NameTypeFormatDescription
fieldstringThe field we wish to query
[operator]anyThe value we want to evaluate with the chosen operator

Filter

NameTypeFormatDescription
[key]stringkey-safe-no-spacesThe filter key used to identify the filter, and in any route parameters or query string
titlestringThe title to render next to the filter
contentTypeIdstringoptionalThe content type id we will dynamically load entries from and load into state under the items[]
fieldIdstring / string[]optionalThe content type field(s) we will apply the filter key to, to filter the list of returned results. You can use 'sys.contentTypeId' to filter your results by a specific content type id defined as a FilterItem[].key. Supply an array of fieldIds to have the search filter your results by any provided values in multiple fields for a given filter key.
fieldOperatorstringoptionalThe Delivery API operator we will use when applying any selected filter
itemsobject[]FilterItem[]Supply an empty array or a hardcoded list of FilterItem depending on the type of filter we require. To filter by a list of content types, supply an array of FilterItem[{ key, title }]
logicOperatorstringoptionalThe Delivery API logical operator we will use when applying any selected filter, e.g. 'and', 'or' - default is 'or'.
renderablebooloptionalAdd false to indicate we do not wish to render this filter in our exposed filter prop
customWhereobject[]optional CustomWhereClauseAn array of CustomWhereClause to include in the search query when dynamically loading entries via the contentTypeId key

FilterItem

NameTypeFormatDescription
keystringThis will usually be the entry id or the taxonomy key
titlestringThe title to render next to the filter item
pathstringoptionalThis will usually be the entry slug or the taxonomy path
isSelectedbooloptionalWhether the filter is in a selected state