Search-Result Data Source
9 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 input component 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 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 — deprecated group results by a custom content property — requires legacymode unwrapbundles which is itself deprecated for common properties ( contextkey , limit , batchsize , etc ) see data sources overview docid\ fumbuabweon oto5wfevf 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 da sort properties sort key type description relevance { direction } sort by relevance score (default) publicationdate { direction } sort by publication date direction accepts asc or desc 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 short queries very short phrases (1–2 characters) may return unexpected results depending on api configuration related topics content data source docid\ dfdy32zanytmhkuhzxorb data sources overview docid\ fumbuabweon oto5wfevf