4

I'm quite new to search facets with sitecore.

I'm trying to implement a search facet with lucene, where I need to categorize results based on the Parent of the child items.

I tried to use the Location facet which comes by default, but its displaying GUIDs instead of parent names.

Can someone add few pointers or links to a correct resource.

Thank you in advance.

3
  • Sillly question maybe, but are you looking for a solution in a bucket search or in a ContentSearch query? For the bucket, did you check this: sitecore.stackexchange.com/questions/6746/…
    – Gatogordo
    Oct 5 '17 at 17:34
  • @Gatogordo I'm looking for ContentSearch query.. but, its good to know that info on that link you posted also. Oct 6 '17 at 0:51
  • Will you have too many facets to get the names after the query (from the guids)? That would be an easy solution, but could give a performance issue. On the other hand, be aware that storing parent names in the index will lead to extra caution when the parent updates..
    – Gatogordo
    Oct 6 '17 at 9:33
3

It sounds like you are on the right track. What you need is computed index field. You add another field to your index that indexes the parent item name as part of the document that you are indexing. John West has written a blog post about computed index fields here:

https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/sitecore-7-computed-index-fields

In this example he returns a boolean but you can return a string instead.

Next you need to create a new facet under /sitecore/system/Settings/Buckets/Facets where you reference the name of your computed index field.

After that you should be able to facet on the parent item name.

1
  • But what if someone changes the name of the parent? Will the index be updated?
    – Gatogordo
    Oct 6 '17 at 9:26
2

To turn the IDs in your facets into real item names, just enable this setting. This will cause Sitecore to translate facets that are IDs into real item names.

<!-- RESOLVE FACET VALUE TO FRIENDLY NAME
       If you are storing a field in the index that is being faceted on, it may be stored as an ID. This Setting
       when set to true, 
       will try and resolve this to the friendly item name instead. 
       USAGE: In an environment with huge amounts of items (e.g. 1 Million), this will not scale properly.           
  -->
  <setting name="BucketConfiguration.ResolveFacetValueToFriendlyName" value="false"/>

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.