Search-Result Data Source
11 min
overview the search result data source runs a full text search against the catalog api and returns matching content items the search phrase is provided via the phrase config property, which is typically bound to a url query parameter or context value set by the search ui when to use this use search result on any view that displays the outcome of a user's search query the phrase property drives what is searched — when it resolves to an empty value, the data source returns an empty list, which is the correct idle state basic example { "type" "search result", "contextkey" "results", "phrase" "$context phrase", "batchsize" 20, "filter" { "publication" { "id" { "value" "\ publicationid" } } } } $context phrase is typically populated from the url query param ?phrase= at runtime live example view /examples/datasources/search result configuration type specific properties property type default description phrase string — required the search phrase supports $context interpolation — e g "$context phrase" reads from the url query param ?phrase= filter object — scope the search to a subset of content sort array — controls result ordering (default relevance) searchfields string\[] \['content', 'content name'] fields to search in searchoptions object — additional search api options limitcharactersbeforehit number — trim excerpt to at most n characters before the first highlighted hit groupby object — group results by a custom content property (see below) for common properties ( contextkey , limit , batchsize , etc ) see todo insert link to data sources overview link filter properties uses the same filter shape as the content data source ( storefrontcontentfilter ) filter key type description publication publicationfilter restrict results to a specific publication — use publication id contenttype { value, negated? } limit results to a content type post , issue , bundle taxonomies taxonomylistfilter restrict results to specific taxonomy nodes properties mapfilter filter by custom content properties supports and , or , and condition — see todo insert link to data sources overview link sort properties sort key type description relevance { direction } sort by relevance score (default) publicationdate { direction } sort by publication date direction accepts asc or desc groupby properties groups search results by a custom content property requires legacymode unwrapbundles true property type description issuefromcustomproperty string property key to group results by groupissuefilter issuefilter filter used to load the parent issue for each group header fallbackheaderdata object header context data for results that have no matching group advanced features showing results only when a query exists wrap the result list in a condition { "condition" { "value" "$context phrase", "operation" "set" } } trimming excerpts use limitcharactersbeforehit to prevent very long excerpts with the search hit far from the start { "type" "search result", "phrase" "$context phrase", "limitcharactersbeforehit" 100 } testing notes / edge cases empty phrase = no results when phrase resolves to an empty string or undefined, the data source returns zero items always pair with a "no results" empty state preventssrcache search results are user driven — set preventssrcache true on server rendered search pages relevance ordering results default to relevance score a sort override may produce unexpected ordering — test carefully short queries very short phrases (1–2 characters) may return unexpected results depending on api configuration related topics todo insert link to data sources overview linktodo insert link to content data source link