0

I'm using Sitecore 9 and SXA 1.7, I want when the user enters a SXA tag name, all the items tagged by this tag are returned at the search results.

I tried it but no results are returned, I checked the Solr, the tag is indexed : sxatags_sm":["Visitor"].

I made the _Taggable and the Tag templates inherits from _Searchable template and rebuilt the index, but still it's not searchable.

  • Looks like some of the steps you provided are incorrect. You should be using the sxatags field as a facet used by components like Droplist filter. Refer to the SXA documentation site for detailed instructions. – Michael West May 19 at 12:58
  • 1
    I think this discussion can help you:sitecore.stackexchange.com/questions/14149/… – Dawid Rutkowski May 19 at 19:18
  • @MichaelWest Yes I know it, but I have a requirement that user has to search the items by using its tags as a keyword not by filtering it. – Mohamed Yaseen Mosa May 20 at 5:49
  • @DawidRutkowski, I read it, but it's not what I want. I think there is no an OOTB solution for it, I have tried to make a custom one but I couldn't. – Mohamed Yaseen Mosa May 20 at 5:51
2

If I understand you correctly you would like to use Search Box to search item by tags. By the default, it is not possible because Search Box is using Aggregated Content (this field in the index will be named sxacontent) computed field. This field contains only extracted text content of an item and tags are assigned as an IDs.

You have a few options:

  • override AggregatedContent computed field (method ComputeFieldValue()) so that it will also include tags names into the sxacontent index field - in such case Search Box will work as you expect it
  • override ContentPredicate() method in Search Service so that instead of just checking AggregatedContent field it will also take a look for tags
  • re-design your approach and use Filter (Checklist) rendering with tags

I would recommend using the third option. If you would like to take a more advanced approach go with the first option as overriding Search Service is more tricky than simply config update which you have in a first proposition.

  • All right,Thank you this really helped me. – Mohamed Yaseen Mosa May 20 at 8:24
  • I will go with the first option, but which dll do I have to override ? What is its name ? – Mohamed Yaseen Mosa May 20 at 8:28
  • @MohamedYaseenMosa Open Sitecore.XA.Foundation.Search.Solr.config file and look for <field fieldName="sxacontent" returnType="textCollection" type="Sitecore.XA.Foundation.Search.ComputedFields.AggregatedContent, Sitecore.XA.Foundation.Search">. Namespace is defned in type attribute. – Dawid Rutkowski May 20 at 9:39

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.