Gravatar for topazahmed@gmail.com

Question by topaz, Sep 2, 2016 2:26 PM

how do I get coveo field name on a coveo pipeline

 public class MapShrinkerPipeline : IProcessor<CoveoProcessParsedRestResponseArgs>
{
    public void Process(CoveoProcessParsedRestResponseArgs p_Args)
    {
        SearchResponse response = p_Args.ResponseContent;
        foreach (SearchResult result in response.Results)
        {
            foreach (string key in result.Raw.Keys)
            {
                if (key.Contains("templateid"))
                {
                    if (result.Raw[key].Equals(Guids.Templates.Map.Replace("{", "").Replace("}", "")))
                    {
                        //do stuff here
                    }
                }
            }
        }

Above is how i am doing it now.

but tried the method described in https://developers.coveo.com/display/public/SitecoreV3/Removing+Fields+From+Search+Results

contextItem is null, so above method is not working.

any ideas?

1 Reply
Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Sep 2, 2016 2:56 PM

Hi,

First, let me explain you some concepts, you seem to be mixing up a couple of things here.

  1. A pipeline contains multiple processors.
  2. From code, you invoke a pipeline.
  3. Processors are invoked 1 by 1 by the pipeline in the order they are defined in your configuration.
  4. The pipeline calls the process(args) method of your processors with the arguments provided.

You wrote: "I inserted a pipeline before CoveoProcessParsedRestResponseArgs" => You incerted a processor inside the CoveoProcessParsedRestResponse pipeline. Right? If that is not the case, then it is normal that the context item is null.

Is your ResolveResultClickableUriProcessor working? This processor validates that the context item is not null => it logs in debug mode.

What is your Sitecore version? CoveoForSitecore version?

Gravatar for topazahmed@gmail.com

Comment by topaz, Sep 2, 2016 3:06 PM

Yes, correct. I have the processor in coveoProcessParsedRestResponse after ResolveResultClickableUriProcessor process

there my context is null but i am looking for a way to get the fields in the Raw results…

how do i get ftemplatename49863 from templatename?

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Sep 2, 2016 3:16 PM

The issue here is not how to get ftemplatename49863 from templatename. Your context item should not be null.

So I ask again: What is your Sitecore version? + CoveoForSitecore version?

Is your context item still null if you place your processor before the ResolveResultClickableUriProcessor?

Gravatar for topazahmed@gmail.com

Comment by topaz, Sep 2, 2016 3:41 PM

I am on sitecore 8.1 coveoforsitecore 3.0.1266.0

I am also wondering if this is right place for the process to take place. I see other pipelines for coveo as well but not sure where to add mine 100%

The problem is that coveo is returning too much data for search results. i get 600 results back which is about 6 mb which takes a long time to load, specially on mobile. i want to trim the data down to what we need so the results will load longer. so i was thinking just insert a process to find specific items by template and get exclude files from the raw data.

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Sep 2, 2016 3:55 PM

I see… There is obviously place for improvements. In 3.0.1266, a new functionality was added to reduce the number of fields used. You should check that out: https://developers.coveo.com/display/public/SitecoreV3/Understanding+the+coveoIndexingGetFields+and+coveoIndexingGetTemplates+Pipelines.

Another improvement which will drastically reduce the number of fields in in our pipeline, but that will be for a future release.

600 results is a lot, do you really need all these?

If you do operations on your search results, and those operations can be performed at indexing time, then you should do it at indexing time: Search response time has way more important for your "search users" than indexing time. May I ask what operation you are trying to do in this pipeline?

Gravatar for topazahmed@gmail.com

Comment by topaz, Sep 2, 2016 4:27 PM

thanks for that

appreciate the info the flow helps

but i am still confused why the link below is not working for me https://developers.coveo.com/display/public/SitecoreV3/Removing+Fields+From+Search+Results

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Sep 2, 2016 4:42 PM

I'm still wondering what the answer to these questions might be:

  1. Is your context item still null if you place your processor before the ResolveResultClickableUriProcessor?

  2. Is your ResolveResultClickableUriProcessor working? i.e. what is the format of your URLs on an OOTB Coveo search page?

  3. (Optional) May I ask what operation you are trying to do in this pipeline?

New question:

  1. Are you sure the problem is the context item being null and not something else?
Ask a question