Gravatar for wvuong@captechconsulting.com

Question by wvuong, May 12, 2016 7:31 PM

Multi Value Computed Field

I am trying to create a multivalue computed field, but my field ends up only have the last value of the list. I am using Coveo for Sitecore 4 Cloud Edition

i have the following field declarations

<fieldType fieldName="my custom field" isFacet="true" isMultiValue="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework"/>

<field fieldName="my custom field"> package.computedfield, package</field>

And for the computed field I am returning a List object. The end goal is to use this field for query suggestions.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 13, 2016 10:49 AM

Your field declarations seems all right and returning a List<string> works for me.

Can you debug your code with a breakpoint at indexing time and validate that you have more than one string in your list before returning it?

Also validate that the indexed date of the document in the Content Browser is updated before validating the indexed field value.

By the way, when setting isMultiValue="true", isFacet="true" is optional. Setting a field as a multi-value will automatically set it as a facet.

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 13, 2016 1:02 PM

I have validated that there is more than one item in the list. I did notice that the indexed date doesn't reflect that it has been updated, even though the status for the source shows that it has gone through the process recently

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 13, 2016 1:22 PM

Look at the activity logs for the sources, they are rebuilding but are not processing any items

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 13, 2016 1:38 PM

Hi William,

When a Coveo Cloud source states that a rebuild operation was completed, it means the documents were all received in the Push API endpoint but it doesn't mean the document processing is finished and that the documents are searchable yet.

The documents need to go through a series of steps to convert and index them before they become searchable.

So when you trigger a rebuild or a re-index of Sitecore items, you should always wait until the Content Browser shows an updated index date equal to the date of your indexing operation before validating your indexed documents content and field values.

At the moment, we see that your index has a lot of documents pending for conversion. This can be explained by multiple successive rebuild operations triggered on your side while testing/developing your solution. I recommend you to wait until the indexed date of your indexed documents match the last time you rebuilt before rebuilding again.

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 16, 2016 9:34 AM

My indexes have been rebuilt and I have confirmed with the indexed date and also confirmed through debugging the computed field that the list I return has two items, yet the value for my field only has the last item.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 16, 2016 9:45 AM

Very strange.

Is it possible that your field value get overwritten by another piece of code after it's originally computed?

Is it possible that you have configured 2 computed fields for the same field name? Check in ShowConfig.aspx

Is it possible that you have configured a coveoPostItemProcessingPipeline or another pipeline processor that modifies the field value?

To troubleshoot furthermore, I recommend you to write a coveoPostItemProcessingPipeline processor that does nothing but allows you to set a breakpoint to inspect the fields and their values at indexing time. This way, you will be able to see what's the value for this field just before the item is sent to the Coveo Cloud Push API.

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 16, 2016 10:15 AM

I have confirmed that I don't have multiple computed fields with the same name, and I added a pipeline just for debugging purposes that is last and confirmed that there are two values in the field in the following format: "foo;bar". I confirmed the indexed date in the content browser and its still only showing the "bar" value.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 16, 2016 11:43 AM

I'm out of ideas right now. Can you share the computed field code?

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 16, 2016 1:12 PM

Code:

public object ComputeFieldValue(IIndexable indexable)
{
    SitecoreIndexableItem indexableItem = indexable as SitecoreIndexableItem;
    if (indexableItem != null && indexableItem.Item.TemplateID == IPhysicianModelConstants.TemplateId)
    {
        List<string> suggestions = new List<string>();
        SitecoreContext context = new SitecoreContext(indexableItem.Item.Database);
        PhysicianModel physician = context.GetItem<PhysicianModel>(indexableItem.Item.ID.Guid);
        suggestions.Add(BuildPhysicianTitle(physician));
        suggestions.Add("test me");
        return suggestions;
    }
    return null;
}

BuildPhysicianTitle just creates a string.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 16, 2016 2:18 PM

Is it possible that you changed the default multiple value separator by setting the /configuration/sitecore/coveo/defaultIndexConfiguration/multipleValueSeparator element value? Can you check in the ShowConfig.aspx to confirm you didn't modified it?

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 16, 2016 2:21 PM

Confirmed that I do not have that element set. For what its worth, I have another field that i created before the 3.0 to 4.0 migration that returned a list of strings and is being recognized correctly.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 16, 2016 3:34 PM

I have an idea. Is it possible that the name you gave to your computed field is also the name of a Sitecore field set on a Sitecore template? If so, is it possible that the type of both fields are not compatible?

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 16, 2016 4:18 PM

I changed the name, rebuilt, the indexes and now Coveo is correctly recognizing the the multi-value field. Although I don't think the original field name I had was being used somewhere else. I will do more research and get back to you.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 17, 2016 11:22 AM

Which version of Coveo for Sitecore 4.0 are you using? Build 171?

Gravatar for wvuong@captechconsulting.com

Comment by wvuong, May 17, 2016 11:24 AM

Yeah 4.0.171.0

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 17, 2016 12:12 PM

Alright. That's perfect. The previous 4.0 build (that lived only 1 day) contained a small bug in the fields area that would have maybe explained your issue if your field type had changed between 2 indexing operations. This can not happen with 4.0.171.

I'm glad you successfully solved the issue by renaming the field.

You can check the fields configuration in Coveo Cloud Administration Console in the "Search Content > Fields" section. Can you try finding the old and the new field and click on Edit for both to compare their configuration?

0 Reply
Ask a question