CoveoProcessParsedRestResponseArgs add new fields to response/result from parent of result
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.
- 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.
- "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.
- 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.
- The method SitecoreUtilities.ToCoveoFieldName has been removed from C4SC 4.0 (A necessary step to some features).
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.