You need to meet certain criteria to allow your data items to be visible in search results.
Important
Although it is possible to achieve that via configuration please bear in mind that none of the default templates contains layout, thus you will not be able to display them (when you open item using link) and there might be weird behaviours with links as root path of your site is normally Home
item, located directly under the site. What it means links to those data items will contain more than a minimal path and might expose content path.
Configuration
Template inheritance
Your data items have to use a template which inherits from _Searchable
(/sitecore/templates/Foundation/Experience Accelerator/Search/Computed Fields/_Searchable
)
Thanks to this field, SXA will add computed field for each item during indexing.
Add associated content
If not specified explicitly search results will be narrowed to the current site.
You can extend it adding additional nodes to Associated Content
.
Create appropiate rendering variant
It depends how you will consume your results. If you are going to display them on a page using default searach results rendering remember about valid Rendering Variant (notice Text
field, which is a part of Text
template)
Consume results
Rebuild tree/index and after that, you can consume your data items
Searching via search box (query)
If you need to filter items using search query (q
parameter) I think you will need a custom code.
Search phrase provided via q
parameter is used to search items in the index by comparing sxacontent
field. This is a computed field (Sitecore.XA.Foundation.Search.ComputedFields.AggregatedContent, Sitecore.XA.Foundation.Search
).
The problem I see is this line
if (!item.IsPageItem() && !IsPoi.Verify(item))
{
return null;
}
Computed field logic will return null
for items other than page items or POIs.
I think you will have to modify the code of AggregatedContent
class to include at least display name of your data item into the computed field.