1

Is there a way to include the content in the Data folder in the search results?

when I search for an item using the search box it doesn't show up and I get 0 results but when the search box query is empty the items show up

the items inherit from _searchable and included only if I move them under the home. Any help is appreciated

  • How would you want them displayed tho? The data items are not pages that can be linked to. – Richard Seal May 21 '18 at 14:09
  • Can you please try to create search scope and apply it on search results component? – Amit Kumar May 21 '18 at 17:01
  • @RichardSeal with SXA everything is possible - it's just a matter of proper rendering variant. And Search Results rendering is using them to display results. – Dawid Rutkowski May 21 '18 at 18:07
  • @Mshaltaf Try with the search settings which are located on the Settings item in your site. – Dawid Rutkowski May 21 '18 at 18:08
  • @DawidRutkowski I have tried the settings and already created a scope that includes the data folder and if there is no text in the search box the search result returns all the items including the ones in the data folder but once I type in the search box the items from the data folder disappear and only the items that under the home are displayed – Mshaltaf May 22 '18 at 6:47
3

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)

enter image description here

Thanks to this field, SXA will add computed field for each item during indexing. enter image description here

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.

enter image description here

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)

enter image description here

Consume results

Rebuild tree/index and after that, you can consume your data items enter image description here

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.

|improve this answer|||||
  • We already applied this and the items are showing up in the search result but once there is a search query the items are not found – Mshaltaf May 24 '18 at 8:27
  • @Mshaltaf I updated my answer -> section Searching via search box (query) – Alan Płócieniak May 24 '18 at 8:58
0

We had the same issue when we migrated the items from 8.1 to 9.0.1 (SXA Storefront Site).

We have to add SXA Page template inheritance to our 8.1 base template.

Here is the snip it

SXA Storefront Page base template

enter image description here

Migrated 8.1 Base template for Pages added with base template like SXA Storefront Page

enter image description here

After this our search results page in SXA Storefront showed the pages migrated from 8.1

Hope this help whoever works in Sitecore 8.1 to 9.0.1 migration with SXA Storefront site.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.