Gravatar for dipsindol@gmail.com

Question by DEEPTHI KATTA, Oct 4, 2016 5:43 PM

CoveoProcessParsedRestResponseArgs add new fields to response/result from parent of result

Hi,

I am trying to achieve the below - https://developers.coveo.com/display/public/SitecoreV4/Altering+Search+Results+Before+They+Are+Displayed+in+a+Search+Interface

On Sitecore 8.1, update 2. I was successfully able to patch on to the pipeline and could hit the breakpoint. What I want to achieve is read through the results and add additional fields from a parent of the result. For example if B is the result and A is the parent, I want to grab some x field from A the parent and plop that value up in the result object. something like result["x"] = Field value from A

What is the best way to achieve this? I have noted that the raw fields have Item ID of the result and using the sitecontext in p_Args I can grab the parent of the result item and get the data I need. My only concern is this is a good practice or there are better ways? Also, I do see that Raw fields have Coveo Index names and not sitecore field name, Does this mean I have to call tocoveofieldname and would this work? I am assuming since this is system sitecore field it should have same coveo field name.

FYI, I dont see the method ToCoveoFieldName in SitecoreUtilities after adding COveo.UI in my using.

alt text Thoughts?

2 Replies
Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Oct 5, 2016 8:10 AM

  1. I would use computed fields instead of the processParsedRestResponse pipeline to achieve what you are trying to do. You want your search to be as fast as possible, so if you can remove processing from the processParsedRestResponse pipeline and transfer it at indexing time, do it.
  2. "What is the best way to achieve this?": Computed fields. You might want to look at the OOTB referenced computed field, although it might not do exactly what you want.
  3. Does this mean I have to call tocoveofieldname and would this work?: In computed fields, you have access to the real Sitecore item => you won't have to deal with Coveo field names.
  4. The method SitecoreUtilities.ToCoveoFieldName has been removed from C4SC 4.0 (A necessary step to some features).
Gravatar for dipsindol@gmail.com

Comment by DEEPTHI KATTA, May 17, 2017 10:34 PM

I have noticed a huge concern with this approach. I am trying to access parent's value in computed field. So, in real life scenario when parent is modified and published, Coveo does not consider re-running the computed field logic as the actual item on which kind of want to reflect when a parent is changed. How can we achieve one of the following -

1. When parent is modified update the computed field on child items

2. Ensure Coveo considers running computed field logic on all children when parent is in the delta of modified.

Gravatar for dipsindol@gmail.com

Answer by DEEPTHI KATTA, May 20, 2017 9:26 PM

I found an answer to this looking through some of Coveo's documentation. You will need to patch on to Coveo Item processing pipeline to add related items to args list to ensure coveo re-builds the children when a parent is modified in cases like this.

Ask a question